Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
161 views

Linux Commands

Uploaded by

shahzaibali39390
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

Linux Commands

Uploaded by

shahzaibali39390
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Linux Commands

The Linux command is a utility of the Linux operating system. All basic and advanced tasks can be done by
executing commands. The commands are executed on the Linux terminal. The terminal is a command-line
interface to interact with the system, which is similar to the command prompt in the Windows OS. Commands
in Linux are case-sensitive.

Linux terminal is a user-friendly terminal as it provides various support options. To open the Linux terminal,
press "CTRL + ALT + T" keys together, and execute a command by pressing the 'ENTER' key.

Linux Directory Commands


1. pwd Command

The pwd command is used to display the location of the current working directory.

Syntax:

pwd

Output:

2. mkdir Command

The mkdir command is used to create a new directory under any directory.

Syntax:

mkdir <directory name>

Output:

3. rmdir Command

The rmdir command is used to delete a directory.

Syntax:

rmdir <directory name>

Output:
4. ls Command

The ls command is used to display a list of content of a directory.

Syntax:

ls

Output:

5. cd Command

The cd command is used to change the current directory.

Syntax:

1. cd <directory name>

Output:

Linux File commands


6. touch Command

The touch command is used to create empty files. We can create multiple empty files by
executing it once.

Syntax:

1. touch <file name>


2. touch <file1> <file2> ....

Output:
7. cat Command

The cat command is a multi-purpose utility in the Linux system. It can be used to create a
file, display content of the file, copy the content of one file to another file, and more.

Syntax:

cat [OPTION]... [FILE]..

To create a file, execute it as follows:

cat > <file name>


// Enter file content

Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as
follows:

cat <file name>

Output:

8. rm Command

The rm command is used to remove a file.

Syntax:

rm <file name>

Output:

9. cp Command

The cp command is used to copy a file or directory.


Syntax:

To copy in the same directory:

cp <existing file name> <new file name>

To copy in a different directory:

Output:

To copy in a different directory:

cp <existing file name> <directory path>

Output:

10. mv Command

The mv command is used to move a file or a directory form one location to another
location.

Syntax:

mv <file name> <directory path>

Output:

use the following syntax to rename a file in Linux with the mv command:
mv old_filename.txt new_filename.txt

Linux File Content Commands


11. head Command

The head command is used to display the content of a file. It displays the first 10 lines of a
file.

Syntax:

head <file name>


Output:

12. tail Command

The tail command is similar to the head command. The difference between both
commands is that it displays the last ten lines of the file content.

Syntax:

tail <file name>

Output:

13. tac Command

The tac command is the reverse of cat command, as its name specified. It displays the file
content in reverse order (from the last line).

Syntax:

1. tac <file name>

Output:
Linux User Commands
14. su Command

The su command provides administrative access to another user. In other words, it allows
access of the Linux shell to another user.

Syntax:

su <user name>

Output:

15. useradd Command

The useradd command is used to add or remove a user on a Linux server.

Syntax:

useradd username

Output:

16. passwd Command

The passwd command is used to create and change the password for a user.
Syntax:

passwd <username>

Output:

17. userdel command


To delete a user, use the userdel command:
userdel username

18. clear command


The clear command is a standard command to clear the terminal screen.

19. man command


The man command displays a user manual for any commands or utilities
available in the Terminal, including their name, description, and options.
Command to view the full manual:
man <command name>
For example, suppose you want to look up the manual for the ls command:
man ls

20. echo command


echo command in Linux is specially used to print something in the terminal

You might also like