Linux Commands

Connect to the remote server

ssh <username>@<ipaddress>

Create file

vi <file name>

Save file


Save and Quit


Quite without saving


Copy File

cp <filepath>/<filename>  <target file path>/<filename>

Move file

mv <filepath>/<filename>  <target file path>/<filename>

Remove File

rm <filepath>/<filename>

Search In file

:/<string to search>

Search and replace all in file

:%s/<search string>/<replace string>

Go to the specific line

:<line number>

Copy remote file to the local

scp <remoteuser>@<remote ip>:<remote path>/<remote file name> <local path>

Open file as read only

cat <file path>/<file name>

Create directory

mkdir <directory name>

Check directory

cd <directory name>

List all files from folder or directory

cd <folder path>

List file with an order

cd <folder path>
ls -lah

Remove file recursively

cd <folder path>
rm -r *

Remove files forcefully recursive

cd <folder path>
rm -rf *

Categories: Linux