Essential Commands in Linux

Amit JajooAmit Jajoo
2 min read
  1. uptime → give the system start time

  2. man command_name → give the complete information about the command

  3. 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).

  4. kill process_id → The process is killed forcefully.

  5. 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 using sudo apt install htop. To exit, press Ctrl + C

  6. 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.

  7. free → It give the information about RAM. It is generally recommended to use free -h because it displays the size in human-readable format.

  8. history → history provides information about previously run commands. We can also rerun a command by using !id, where id is the number shown in the history list.

  9. history -c && history -w → Clear the history for the current session and prevent it from being saved.

  10. 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.

  11. which program_name → provides information about the location of the binary file.

  12. 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.

  13. tail -f file_name. →Displays real-time information about the logs.

0
Subscribe to my newsletter

Read articles from Amit Jajoo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Amit Jajoo
Amit Jajoo