Home > Common Problem > body text

Commonly used shell commands in Linux

百草
Release: 2023-10-07 11:01:30
Original
1876 people have browsed it

Commonly used shell commands in Linux include cd, ls, pwd, mkdir, rm, cp, mv, touch, cat, less, grep, find, chmod, chown, chgrp, tar, wget, ssh, scp and top etc. Detailed introduction: 1. cd, used to switch the current working directory; 2. ls, used to list the files and subdirectories in the directory; 3. pwd, used to display the path of the current working directory; 4. mkdir, used to create a new Directory; 5, rm, etc.

Commonly used shell commands in Linux

Linux, as an open source operating system, provides a wealth of shell commands for management and operating systems. Below I will introduce some commonly used Linux shell commands to help you better understand and use the Linux system.

1. cd: used to switch the current working directory. For example, cd /home switches the current directory to the /home directory.

2. ls: used to list files and subdirectories in a directory. For example, ls /home will list the files and subdirectories in the /home directory.

3. pwd: used to display the path of the current working directory. For example, pwd will display the path of the current working directory.

4. mkdir: used to create new directories. For example, mkdir test will create a new directory named test under the current directory.

5. rm: used to delete files or directories. For example, rm file.txt will delete the file named file.txt in the current directory.

6. cp: used to copy files or directories. For example, cp file.txt /home copies the file file.txt to the /home directory.

7. mv: used to move files or directories, or rename files or directories. For example, mv file.txt /home moves the file file.txt to the /home directory, and mv old.txt new.txt changes the file name from old.txt to new.txt.

8. touch: timestamp used to create new files or update files. For example, touch file.txt will create a new file named file.txt in the current directory.

9. cat: used to view file contents or merge multiple files into one file. For example, cat file.txt will display the contents of the file file.txt.

10. less: used to view file contents in pages. For example, less file.txt will display the contents of the file file.txt in paginated format.

11. grep: used to search for specified patterns in files. For example, grep "hello" file.txt will search the file file.txt for lines containing the string "hello".

12. find: used to find files or directories in the file system. For example, find /home -name "file.txt" will look for a file named file.txt in the /home directory and its subdirectories.

13. chmod: used to modify the permissions of files or directories. For example, chmod 755 file.txt sets the permissions of the file file.txt to 755.

14. chown: used to modify the owner of a file or directory. For example, chown user file.txt changes the owner of file file.txt to user.

15. chgrp: used to modify the group to which a file or directory belongs. For example, chgrp group file.txt changes the group of the file file.txt to group.

16. tar: used to pack and unpack files. For example, tar -cvf archive.tar file1 file2 will package the files file1 and file2 into a file named archive.tar, and tar -xvf archive.tar will unpack the file named archive.tar.

17. wget: used to download files from the network. For example, wget http://example.com/file.txt will download the file file.txt from http://example.com.

18. ssh: used to log in to a remote host through a secure remote connection. For example, ssh user@host will log in to the remote host named host through the SSH protocol.

19. scp: Used to copy files between local host and remote host through a secure remote connection. For example, scp file.txt user@host:/home copies the file file.txt to the /home directory of the remote host named host.

20. top: Used to view the running status and process information of the system in real time. For example, top will display the system's real-time performance data and process list.

The above are just some of the commonly used shell commands in Linux. There are many other commands that can be used for different operations and management tasks. By mastering these commands, you can manage and operate your Linux system more efficiently. At the same time, Linux also supports script programming, which can combine multiple commands to achieve more complex operations and automation tasks. I hope these commands can help you make better use of your Linux system.

The above is the detailed content of Commonly used shell commands in Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!