The 20 most popular SSH commands

The most popular 20 SSH commands are the most common commands so anyone should know to be able to manage and control your Linux VPS.

Before you start, you need to connect to the VPS via SSH using the Putty tool or the ZOC Terminal (You should use ZOC for easier copy / paste).

Note:

  • Directories, paths to directories usually end in characters /
  • File, the path to the file has no characters /at the end
  • A file on Linux does not always have a tail behind it

The 20 most popular SSH statements

1. Move between folders

cd [another directory]

For example, go to the directory containing the Nginx configuration file

cd /etc/nginx/conf.d/

2. Go to the user’s home directory

cd ~

If you login with the account rootthen the home directory will be/root

3. Go to the previous folder

cd -

4. Scroll to the parent folder

cd ..

5. Displays the current directory path

pwd

Show all files / folders in the current directory

ls

7. Display all files and information

ls -al

8. Display all files with any extension

ls *.ext

Eg show the whole file * .PHP

ls *.php

9. Show all files / folders with detailed information

ls -alh

10. Disable SSH connection

exit

File management

11. Copy and rename the file

Old file remains the same.

cp [filename] [new filename]

Eg copy and rename the banner.jpg file to banner728px.jpg

cp banner.jpg banner728px.jpg

VD: copy banner.jpg into the ads folder and rename it banner728px.jpg

cp banner.jpg ads/banner728px.jpg

12. Move and rename the file

The old file will be deleted and moved to the new folder.

mv [old filename] [new filename]

VD: di chuyển banner.jpg sang folder ads

mv banner.jpg ads/banner.jpg

Eg: move banner.jpg to folder ads and rename the file to banner728px.jpg

mv banner.jpg ads/banner728px.jpg

Similarly, you can move both folders.

For example, move the image folder to the media folder

mv image/ media

Eg: move the image folder to the parent folder

mv image/ ..

13. Delete a file

rm [file name]

Eg delete banner.jpg file

rm banner.jpg

14. Delete the entire file in the current directory

rm *

15. Delete all files with any extension

rm * .ext

Eg delete all .jpg files

rm *.jpg

16. Copy a folder with all files, folders inside

cp -r [directory] [new directory]

17. Create a new folder

mkdir [folder name]

CEO:

mkdir image

18. Search for a file from the current directory

find . -name [filename] -print

Eg: find the banner.jpg file in the current directory

find . -name banner.jpg -print

19. Search for content in a file

grep [text] [filename]

Eg: find the sidebar in the index.php file

grep sidebar index.php

20. CHMOD – change file permissions

chmod [permission type] [file/folder name]

CEO:

chmod 777 wp-config.php

How to set permission:

The first number for the owner file, the second number for the owner group, and the third number for all other users and groups.
7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied

Add Comment