50 Useful Linux Commands - Part 1

50 Useful Linux Commands – Part 1

50 useful Linux Commands – Part 1

Hello everyone, in this two part tutorial, we will learn some very basic Linux commands. Recently I have started learning basic Linux Commands. It is becoming mandatory to keep at least a basic knowledge about Linux Commands. Feel free to share your valuable opinions. Please also mention if you see any mistake as I am a beginner. So lets get started.

 

  1. Create a folder : “mkdir” command is used for creating  a folder. For example, if you e=want to create a folder named “my_directory“, you have to run:
     mkdir my_directory 
  2. Remove a folder: “mkdir” command is used to remove a folder. To remove a folder, you have to run:
     mkdir directory_name 
  3. Show file and folder list: “ls” is one of the most used and popular command. It shows all the files and folders of a directory.
     "ls" 
  4. Show file permissions with hidden file list: “ls” command has some limitations. Such as it doesn’t show the hidden files, also , “ls” doesn’t show the permissions of a file. To get these extra information, you have to run “ls -la
     ls -la 
  5. Copy file: To copy a file to a location, you have to run:
     cp file.txt Desktop/file.txt 

    Note: cp is copy command, then file name, finally directory where you want to copy the file

  6. Move a ile:mv” command is used for moving a file from one directory to another directory.
     mv file.txt Desktop 
    Here, we are moving a file name "file.txt" to Desktop
  7. Read file: To read the internal contents of a file, you have to use “cat” command. Such as:
     cat file.txt 

    Note: “cat” is derived from “concatenate

  8. Find location of a file: “locate” command is used if you want to know location of a specific file.
     locate file.txt 

    Note: This command will give you exact location of any file

  9. Search Indexing: Sometimes a newly created file may not be found by “locate” command. In that case, you have to update the indexing database. For that, you have to run “sudo updatedb”
     sudo updatedb 

    Note: updatedb creates or updates a database used by locate. “sudo” runs this command as superuser. More on this command later.

  10. Explain a command: If you want to know the details of a command, then you have to type “man command_name“. Form Example
     man ls

    Note: this command will give all the details of the command with parameters.

  11. Read file: To read the internal contents of a file, you have to use cat command. Such as:
     cat file.txt 

    Note: cp is copy command, then file name, finally directory where you want to copy the file

  12. Give Read, Write & Execution Rights: To give full read, write and execution power to a file, you have to run below command
     chmod 777 file.txt 

    Note: You have to run this command as super admin

  13. Create user: For creating a new user, below command is used
     adduser

    Note: After running the command, you have to provide user name, password and password confirmation

  14. Show all users: If you want to get the list of all users, run below command
     cat /etc/passwd 

    Note: Here we reading the “/etc/passwd” file, which contains all users info.

  15. Check user hashes: To get users stored hashes, run:
     cat /etc/shadow 

    Note: Be careful of this file. Do not give full access to this file for security reason.

  16. Switch user: For switching to another user, you have to run:
     su user_name 

    Note: Such as, if you want to switch to user jhon, run “su john

  17. Search in a text file: If you want to search in  a text file, you can use below command.
     cat file.txt | grep search_term 

    Note: Here “file.txt” is the file name and the pipe sign, then “grep” with search term.

  18. IP Details: In Windows, we run “ipconfig” to check basic IP related information. If you want to get these data in Linux, you have to run “ifconfig”
     ifconfig 

    Note: It will provide Interface Configuration related data

  19. Wireless info: If you want to get wireless info in Linux, you have to run “iwconfig”
     iwconfig 
  20. Ping command: To check connectivity check from server to server, we run pung command
     ping 192.168.*.* 
  21. Ping for specific time: You you want to run “ping” command for certain times, command is:
     ping -c 5 192.168.*.* 

    Note: above, we will run ping for 5 times

  22. IP address to MAC address mapping: To check IP-address-to-MAC-address mapping, we have to run
     arp 
  23. Check Open ports: To check open ports, you have to run
     netstat -tuplen 
  24. IP routing table: To check IP Routing table, you have to run:
     route 

    Note: cp is copy command, then file name, finally directory where you want to copy the file

  25. Update Packages list and Upgrade Packages: If you want to update all the packages list and also upgrade all the packages in one single command, you have to run
     apt update && apt upgrade 

That’s all for today. In the second part, you will get 25 more basic useful Linux commands. Keep learning folks!

Editorial Staff

A Learner and trying to share what I learned!