Essential Commands in Linux

uptime → give the system start time
man command_name → give the complete information about the command
ps → It stands for Process status. It provides information about all the processes running in the system. Generally we use ps aux command where
a – Show processes for all users, not just your own.
u – Display the process’s user/owner.
x – Show processes not attached to a terminal (e.g., background processes).
kill process_id → The process is killed forcefully.
top → Real-time data is displayed. To kill any process, press
k
and then type the PID. But it's not user-friendly, which is why we use the htop command. We need to install it usingsudo apt install htop
. To exit, pressCtrl + C
df → df stands for "disk free." It provides information about SSD/hard disk partitions and storage usage. It is generally recommended to use df -h because it displays the size in a human-readable format.
free → It give the information about RAM. It is generally recommended to use free -h because it displays the size in human-readable format.
history → history provides information about previously run commands. We can also rerun a command by using
!id
, whereid
is the number shown in the history list.history -c && history -w → Clear the history for the current session and prevent it from being saved.
Press the spacebar and then type the command; it will not save the command or sensitive information in the history. Before using this, check
echo $HISTCONTROL
. If this is set, the below method will work.which program_name → provides information about the location of the binary file.
To set the alias, use
alias staff=‘sudo cat /etc/passwd’
This alias will be saved only for the current session.
To save the alias permanently, use:
vim .bashsrc
(You can find the
.bashrc
file in your home directory.) Then, add your command at the bottom of the file.After that, run
source .bashrc
to load the command into the terminal.tail -f file_name. →Displays real-time information about the logs.
Subscribe to my newsletter
Read articles from Amit Jajoo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
