1
cd [another directory]

example: move to directory “download

1
cd download

2. How to go to home directory

1
cd ~

3. How go to the last directory you were in

1
cd –

4. How to go up a directory level

1
cd ..

5. How to show the full path of the current directory
Use this command to find out where are you currently in.

1
pwd

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

1
ls (just type ls and hit enter)

7. How to list all files and information

1
ls -al

8. How to list all files ending with certain extension

1
ls *.ext

example:

1
ls *.php

9. How to list all files and folders with detailed information including file size

1
ls -alh

10. How to quit and exit SSH client

1
exit

FILE MANAGEMENT

11. How to copy and rename file
Use this command to copy and rename a file

1
cp [filename] [new filename]

example: we’ll rename banner.jpg to banner728px.jpg

1
cp banner.jpg banner728px.jpg

example: we’ll cope banner.jpg to a folder called “ads”

1
cp banner.jpg ads/banner.jpg

example: copying and renaming at once

1
cp banner.jpg ads/banner728px.jpg

ps: original file will remain, it is just copied.

12. How to move and rename file
Use this command to move and rename file

1
mv [old filename] [new filename]

example: moving a file to another directory

1
mv banner.jpg ads/banner.jpg

example: moving a file to another directory and renaming it at once

1
mv banner.jpg ads/banner728px.jpg

ps: original file will be deleted as it was moved to another location
pps: you can also move a folder

example: moving “image” folder to “media” folder

1
mv image/ media

example: moving “image” folder to upper directory

1
mv image/ ..

13. How to delete / remove a file

1
rm [file name]

example:

1
rm banner.jpg

14. How to delete / remove all files in current directory

1
rm *

15. How to delete files with certain extension

1
rm *.extension

example: remove all files with .jpg extension

1
rm *.jpg

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

1
cp -r [directory] [new directory]

17. How to create new folder

1
mkdir [folder name]

example:

1
mkdir image

18. How to search for a file starting within current directory

1
find . -name [filename] -print

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

1
find . -name banner.jpg -print

19. How to search for text within a file

1
grep [text] [filename]

example: find the word “sidebar” in file index.php

1
grep sidebar index.php

20. CHMOD – how to change file permission

1
chmod [permission type] [file/folder name]

example:

1
chmod 777 config.php
Advertisements