Linux Commands Cheat-sheet

All the basic linux commands under 5 minutes !!

These are all the basic linux terminal commands which are required in day to day life. To use these commands, one should open the terminal in linux OS by searching it in menu (GUI) and run these commands as required.

Basic Linux Commands:

  1. To know the present working directory of the user.
    $ pwd
    
  2. Lists all files and directories in the present working directory.
    -R : to lists files in sub-directories as well.
    -a : to lists hidden files as well.
    $ ls
    $ ls -R
    $ ls -a
    
  3. To change to a particular directory.
    use ".." after cd to go to one directory up (back)
    $ cd DIRECTORY_NAME
    $ cd ..
    
  4. To create a new file.
    to displays the file content
    to joins two files (file1, file2) and stores the output in a new file (file3)
    $ cat > FILE_NAME /*or*/ touch FILE_NAME
    $ cat FILE_NAME
    $ cat FILE1 FILE2 > FILE3
    
  5. Moves the files to the new location.
    this same command renames the file to a new filename also.
    $ mv FILE_NAME "new file path"
    $ mv FILE_NAME NEW_FILE_NAME
    
  6. Creates a new directory in the present working directory or a at the specified path.
    this same command renames the file to a new filename also.
    $ mkdir DIRECTOY_NAME
    
  7. Deletes an empty directory.
    $ rmdir DIRECTORY_NAME
    
    8.Deletes a file
    -r : removes a directory which is not empty
    $ rm FILE_NAME
    $ rm -r DIRECTORY_NAME
    
  8. Command used to install and update packages (with install and update options respectively)
    $ apt-get "[install]" "[update]" PACKAGE_NAME
    
  9. Gives manual or information about a command
    $ man COMMAND
    

File administration commands

To perform these administration command, you need to have superuser permissions or you must be a sudoer else use sudo command before every command.

  1. To display file type and access permission in list form
    - la is used to display hidden files also
    $ ls -l
    $ ls -la
    
  2. For changing the ownership of a file/directory.

    $ chown USER_NAME FILE_NAME
    
  3. To change file and directory permissions.

+rwx filename to add permissions.
-rwx filename to remove permissions.
Note: These r w x are used separately also for allowing only respective permissions.

$ chmod +rwx FILE_NAME/DIRECTORY_NAME
  1. To change the group for a file or directory
    $ chgrp FILE_NAME or DIRECTORY_NAME
    

User administration commands

To perform these administration command, you need to have superuser permissions or you must be a sudoer else use sudo command before every command.

  1. To create a new user
    $ sudo adduser USER_NAME
    
  2. To change the password of a user
    $ sudo passwd -l USER_NAME
    
  3. To remove a newly created user
    $ sudo userdel -r USER_NAME
    
  4. To add a user to a group
    $ sudo usermod -a -G GROUP_NAME USER_NAME
    
  5. To remove a user from a group
    $ sudo deluser USER_NAME GROUP_NAME
    
  6. Shows information of all the users logged in
    $ finger
    

Networking commands

  1. To ping and Analyzing network and host connections
    $ ping URL or IP_ADDRESS
    
  2. login into a remote Linux machine using SSH
    $ ssh USER_NAME@IP_ADDRESS
    
  3. Login into a FTP server
    $ ftp IP_ADDRESS
    
  4. To upload files from local computer to remote computer
    $ put FILE_NAME
    
  5. To download files from remote computer to local computer
    $ get FILE_NAME
    
  6. to exit remote connection.
    $ quit OR exit
    

Did you find this article valuable?

Support Gaus Mohiuddin Ahmed by becoming a sponsor. Any amount is appreciated!