Linux is an operating system that many developers will use.
Therefore, it’s a good idea to learn some Linux commands.
In this article, we’ll look at some useful Linux commands we should know.
uname command lets us print details about the current machine and OS running on it.
We can use the
-m switch to show the hardware name.
-p switch prints the processor architecture.
-s switch prints the OS name.
-r prints the release and
-v prints the version.
-n prints the node network name.
-a print prints everything.
man lets us open the help page for a given command.
man <command> to get help with a command.
Man pages are divided into 7 different groups, identified by a number:
1is user commands
2is kernel system calls
3is C library functions
5is files formats and filesystems
7is miscellaneous commands, conventions and overviews
8is superuser and system administrator commands
grep command lets us search for text with a pattern/
For instance, we run:
grep -n document index.md
to search for the
document keyword in the
-n switch lets us show the line numbers of the result.
We can also use
grep to filter the output of another command.
To do this, we run:
less index.md | grep -n document
We open the
index.md file with
less , then we pipe the outline to the
grep command to search for the word
Also, we can invert the result with the
-v option to exclude a particular string.
umask command lets us set default permissions for files.
umask without arguments will show us the current mask.
The mask is the octal number representing the current permissions.
umask -S shows us the permissions with human-readable notation.
The digits return means the following:
0— read, write, execute
1— read and write
2— read and execute
4— write and execute
6— execute only
7— no permissions
We can set a new value by passing it in as an argument:
We can also specify the permission by role:
We can run the
du command to calculate the space usage of files and directories.
We run it to tet the list of items and their sizes in bytes.
-a switch lets us print the size of each file in the directories.
We can sort the results with the
du -h <directory> | sort -nr
history command lets us view the command line history.
We can also use
!<commnand number> to repeat the command with the given number from the
To clear the command history, we run
history -c .
We can list files, search outputs, and command history with various Linux commands.