Important Linux Commands You should know

 Linux provides a CLI (Command Line Interface) to communicate with the OS. Here are the most basic of the Linux Commands:




1. pwd

This command Displays the current working directory of the terminal.

syntax:

$ pwd

2. echo

This command writes its arguments to standard output.

syntax:

$ echo "<text>"

This command is used to switch to root-user so that superuser permissions can be used to execute commands.

3. su

This command is used to switch to a different user whose name is passed as the argument.

syntax:

$ su

4. su <username>

This command is used to switch to a different user whose name is passed as the argument.

syntax:

$ su <username>

5. sudo

This command executes only that command with root/ superuser privileges.

syntax:

$ sudo <command>

6. clear

This command is used to clear the terminal screen. Contents will not actually be deleted in this case, only scrolled down. You can also clear the screen by pressing Ctrl+L on the keyboard.

syntax:

$ clear

Linux Commands: Working with Files

7. cp

This command copies files and directories. A copy of the file/directory copied, still remains in the working directory.

syntax:

$ cp <flag> {filename} /pathname/

8. mv

This command moves files and directories from one directory to another. The file/directory once moved, is deleted from the working directory.

syntax:

$ mv <flag> {filename} /pathname/

9. rm

This command removes files from a directory. By default, the rm command does not remove directories. Once removed, the contents of a file cannot be recovered.

syntax:

$ rm <flag> {filename}

10. grep

This command is used to search for a particular string/ word in a text file. This is similar to “Ctrl+F”, but executed via a CLI.

syntax:

$ grep <flag or element_to_search> {filename}

11. cat

This command can read, modify or concatenate text files. It also displays file contents.

syntax:

$ cat <flag> {filename}

Linux Commands: Working with Directories

12. ls

This command lists all the contents in the current working directory.

syntax:

$ ls <flag>

13. cd

This command is used to change the current working directory of the user.

syntax:

$ cd /pathname/

14. sort

This command sorts the results of a search either alphabetically or numerically. Files, file contents and directories can be sorted using this command.

syntax:

$ sort <flag> {filename}

15. mkdir

This command is used to create a new directory.

16. rmdir

This command is used to remove a specified directory. Although by default, it can only remove an empty directory, there are flags which can be deployed to delete the non-empty directories as well.

syntax:

$ rmdir <flag> {directoryname}

Linux Commands: Working with User Permissions








                  

Comments

Popular posts from this blog

Benefits of InternEzy for students

Blockchain = Block + Chain = listOf(block)

AI a revolutionary invention