Linux Basic Commands: Part 2

MITHIRIDI PRASANTH
2 min readJun 1, 2022

In this post, I will walk you through some more Linux commands that will be useful during your development.

  • sudo: Providing root access to all users is not a good practice. Nonetheless, normal users might need to execute some commands as superuser occasionally. This is where the sudo (Super User DO) access comes into the picture. The sudo command efficiently grants the users special rights to execute commands at the system (root) level. With sudo, we’ll be able to execute administrative tasks without switching users.
    In short, it is used to execute a command as another user. Every command that needs admin privileges needs to use sudo.
    Example: sudo mkdir Test (Prompts for Password)
  • less: It can be used to read the file contents of a file one page(one screen) at a time. It has faster access because if the file is large it doesn’t access the complete file, but accesses it page by page. Use the space bar to go to the next page.
  • more: This command is used to view the text files in the command prompt, displaying one screen at a time in case the file is large.
  • locate: This command searches a database for files and returns a results list.
    Example: locate *.js
  • locate -i: find files by ignoring the case.
    Example: locate -i *.TXT
  • locate — limit: Limits the results found.
    Example: locate — limit 5 *.js
  • find: Search for all the files in a directory hierarchy. This command can be used to execute sophisticated search tasks. You can search by -name,-type, -size.
  • find . -maxdepth: By default find command searches every nested directory. To limit the depth of our search we can use maxdepth options.
    Example: find . -maxdepth 2
  • find . -type: type is used to find only specific types like files or folders.
    Example: find . -type f → Returns only files.
  • sort: This command sorts lines of text files. This command has different options to sort the data. Please check the manual page of this command.
  • grep: The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.
  • zip: This is a compression and file packaging command. The below command compresses the files and creates a test.zip file
    Example: zip -r test.zip file1.txt file2.txt
  • unzip: extracts the compressed files in a ZIP archive.
    Example: unzip test.zip

Thanks for reading this. Will keep adding more commands to this blog. If you have any questions, feel free to leave them as responses. Thanks!

Below are some references that have more details on the Linux commands.

https://www.geeksforgeeks.org/more-command-in-linux-with-examples/

https://www.javatpoint.com/linux-tutorial

--

--