LINUX TUTORIAL: BASH COMMANDS LIST

We will now do a quick up-to-date review of the most commonly used bash commands in the various linux distributions, dividing them by type and syntax.

If you watched our Linux video tutorial for beginners then I encourage you to proceed further, otherwise I recommend that you read the previous lesson so that you can better understand what we will now cover.

One concept we feel it is important to express before proceeding further is the difference between relative path and absolute path.

In Linux, a path refers to the location of a file or directory in the file system hierarchy. The path can be either absolute or relative. Here are the definitions and examples of both:

  1. Absolute path: An absolute path is a full path that starts from the root directory and includes all the subdirectories that lead to a file or directory. The root directory is represented by a forward slash (/).

For example:

/home/user/Documents/example.txt

In this example, /home is the directory that contains the user’s home directory, and user is the username of the user who owns the home directory. The full path to the file example.txt is /home/user/Documents/example.txt. This is an absolute path because it specifies the full path starting from the root directory.

  1. Relative path: A relative path is a path that specifies the location of a file or directory relative to the current working directory. It does not start from the root directory but from the current directory.

For example:

Documents/example.txt

In this example, Documents is the directory that contains the file example.txt. If the current working directory is /home/user, then the relative path to the file example.txt is Documents/example.txt. This is a relative path because it specifies the path relative to the current working directory.

Another example:

../Pictures/photo.jpg

In this example, .. represents the parent directory of the current working directory. If the current working directory is /home/user/Documents, then the relative path to the file photo.jpg in the Pictures directory is ../Pictures/photo.jpg.

In summary, the key difference between absolute and relative paths is that absolute paths specify the full path starting from the root directory, while relative paths specify the path relative to the current working directory.

In the following topics we will use only terminal (shell) bash commands.

The bash commands described here are fairly common for all Linux distributions; variations are minimal.

HELP COMMANDS

COMMAND NAME DESCRIPTION SYNTAX NOTES
--help Show a short help screen related to a command command_name --help ls --help shows a help screen on the ls command
man Shows more detailed guidance related to the specified command. It is the actual manual for all shell commands  man command_name man ls shows the manual page about the whole ls command, its options and arguments

FILE MANAGER AND FILE SYSTEM

COMMAND NAME DESCRIPTION SYNTAX NOTES
pwd Show the path to the directory we are in pwd
ls Displays the list of files and folders in the directory we are in ls [option] [directory] Learn More
cd Used to move within the directories of the filesystem cd [directory] Learn More
touch The touch command is used to update the date of the last access or that of the last modification of a file. If followed by a file name not yet present, it creates a blank one with the given extension touch [options] file Learn More
mkdir Create a directory mkdir [foldername] mkdir fish creates a directory called fish
mv With this command you can move files or directories (move). It can also be used to rename a file or directory mv [options] Source Dest Learn More
cp Copy one or more files to a specific location cp [options] Source Dest Learn More
cat View and concatenate the contents of files cat [options] [file] Learn More
rm Delete Files. You can use -r option to remove each listed directory too, along with all of its contents rm [options] [file] Learn More
more Displays the contents of a file in multiple video pages. The Enter key advances the view line by line while the space bar advances video pages. To exit use CTRL+Z more [options] [file] Learn More
less It features the same functions as more command but improved. Also usable concatenated with other commands less [options] [file] or command_name | less [options] Learn More

SYSTEM COMMANDS

COMMAND NAME DESCRIPTION SYNTAX NOTES
free Display memory status and usage free
df Display free disk space df [option] [file] You can use df -h for a quick and easy report or you can Learn More about this command
ps Process status, information about processes running in memory ps [options] You can use ps -aux for check most useful and essential information about processes. Learn More for other options
top Alternative to ps command with real-time monitoring. Find the CPU-intensive programs currently running top [options] Learn More
uname Display system information uname [options] Learn More
ip Show / manipulate routing, devices, policy routing and tunnels Learn More You can also use ifconfig (deprecated on modern distros)

GO TO PREVIOUS LESSON ⬅                                                                                                                                     ➡  GO TO NEXT LESSON