Useful Basic Linux Commands

basic linux command

pwd command

PWD stands for Print Work Directory. Use the pwd command to find out the path of the current working directory (folder) you’re in.

jobs command

jobs command will display all current jobs along with their statuses.

cd command

To navigate through the Linux files and directories, use the cd command.

cd .. (with two dots) to move one directory up
cd to go straight to the home folder
cd- (with a hyphen) to move to your previous directory

ls command

ls command is to to list computer files and directories

ls -R will list all the files in the sub-directories as well
ls -a will show the hidden files
ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.

cat command

Concatenate files and print on the standard output. Cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.cp command

CP stands for copy. This command is used to copy files or group of files or directory.

mv command

The mv command is a command line utility that moves files or directories from one place to another.

mkdir command

Mkdir stands for “make directory”. The mkdir command allows the user to create directories.

rmdir command

mdir command is used remove empty directories.

rm command

rm is a command-line utility for removing files and directories.

touch command

The touch command allows you to create a blank new file through the Linux command line.

locate command

locate command in Linux is used to find the files by name.

find command

Similar to the locate command, using find also searches for files and directories. The difference is, you use the find command to locate files within a given directory.

grep command

grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Grep stands for “Global regular expression print”.

sudo command

The sudo command. The sudo command allows you to run programs with the security privileges of another user (by default, as the superuser). Sudo stands for “superuser do”.

df command

The df command (short for disk free), is used to display information related to file systems about total space and available space.

du command

Du command that allows a user to gain disk usage information quickly.

head command

The head command is a command-line utility for outputting the first part of files given to it via standard input.

tail command

The tail command, as the name implies, print the last N number of data of the given input.

diff command

Short for difference, the diff command compares the contents of two files line by line.

tar command

The tar command is the most used command to archive multiple files into a tarball — a common Linux file format that is similar to zip format, with compression being optional.

chmod command

The chown command allows you to change the user and/or group ownership of a given file, directory, or symbolic link. chown stands for “change owner”.

kill command

kill command is a built-in command which is used to terminate processes manually.

ping command

The ping command sends packets of data to a specific IP address on a network, and then lets you know how long it took to transmit that data.

wget command

The wget command is a command line utility for downloading files from the Internet.

uname command

The command uname displays the information about the system.

top command

top command is used to show the Linux processes

history command

history command keeps a list of all the other commands that have been run from that terminal session, then allows you to replay or reuse those commands instead of retyping them.

man command

The man command is used to view a system’s reference manuals(man pages).

echo command

echo command in linux is used to display line of text/string that are passed as an argument

zip, unzip command

Use the zip command to compress your files into a zip archive, and use the unzip command to extract the zipped files from a zip archive.

hostname command

hostname command is used to view or change a system’s domain and hostname.

useradd, usermod, userdel command

useradd command is used to create new accounts, usermod command used to modify the existing accounts,
userdel command is used to delete local account in linux.

Bonus:

Clear bash history

cat /dev/null > ~/.bash_history

Flush back to the file when you log out

cat /dev/null > ~/.bash_history && history -c && exit