Basic SHELL Commands For Putty

Windows users can log into their server using Putty which is a free SSH,

Telnet and Rlogin client. Putty can be Downloaded here.

No setup is required – it is a standalone executable. Run Putty, enter your IP address into the Host Name (or IP address) field, the port on which your server SSH service is listening, SSH for protocol and then click on Open.

1. Change Password

passwd

To change password type passwd then enter the old password and again type a new password, again verify the new password.

2. Update and Upgrade

apt-get update
apt-get -s upgrade

3. How to  find the current directory

pwd

Type pwd to see where on the server you are.

For example, if I type pwd in PuTTy it returns /root

4. Navigate

cd

The cd command (also known change directory) is used to navigate to a specified directory on your server.

Such as: cd /home (moves you into the home folder)

If you want to come into same directory then enter

cd.

5. How to get root access without root user details?

sudo su

6. How to move and rename file

Use this command to move and rename file

mv

example: moving a file to another directory

mv earngurus.jpg home/earngurus.jpg

moving a file to another directory and renaming it at once

mv image.jpg home/image2.jpg

7. How to delete / remove a file

rm [file name]

example:

rm earngurus.jpg

8. Copying a file

cp

To copy a file just use the cp ssh command.

Example:

cp file.php /home/file.php

Copy a folder with all files

cp -r

This one is used to copy the entire folder with all its contents.

Copy and rename

cp file.php /home/file2.php

9. How to copy a folder with all files and folders in it

cp -r [directory] [new directory]

10. How to create new folder

mkdir [folder name]

example:

mkdir image

11. Search for a file

find . -name [filename] -print

example: find a file called “file.jpg” in current folder

find . -name file.jpg -print

12. Create a file

touch

Use the touch command to create different files and file extensions (you can later edit them)

Example: touch index.php, touch index.html, touch robots.txt

13. how to change file permission

chmod [permission type] [file/folder name]

example:

chmod 777 index.php

14. How to list files and/or directories in a directory

ls

list all files and information

ls -al

Show contents with file size

ls -h

15. Create a new user account

adduser

16. Compressing folders

zip -r foldername.zip foldername

example: zip -r newfolder.zip newfolder

17. Decompressing folders

unzip

Example: unzip newfolder.zip

18. Compressing folders using tar -czvf

tar -czvf foldername.tar.gz foldername

Example: tar -czvf wp-content.tar.gz wp-content

19. Decompressing folders using tar -czvf

tar -xvf foldername.tar.gz

Example: tar -xvf wp-content.tar.gz

20. check usage memory

free -m

21. Monitor CPU, processes and memory

top

22. Display sever disk usage

df -h

You may also like...