I used to have a google document where I keep track of some handy SSH command list. I will refer back to the list whenever I use SSH Shell command. After some time I am no longer need the list since most of the handy commands are already bared in my mind. Now the list is here and I hope it will help you in a way especially if you are new to SSH.
cd ..
cd -
grep -lr "keyword" /YOUT_PATH/DESTINATION_FOLDER
tar -cvf xxx.tar file
tar -xvf file.tar
scp username@host:/path/to/hosts/file/host_file.txt ~/desktop
IF you are not sure what is the absolute path of your computer, just open a new SSH window, type CD ~, type PWD. This will show you where is your default directory when you use SSH to the server. Simply use scp username@host:/path/to/hosts/file/host_file.txt ~ will download the file to this directory.
scp ~/desktop/file.txt username@host:/path/to/hosts/folder
It's just the reverse way of Downloading a file from the server'
vi file.txt
press the "insert" key to enter edit mode.
press the "Esc" to leave the edit mode, you will still remain inside the VI editor.
List of frequently used commands for VI editor:
:q! : Exit the editor without saving.
:w : Saves the changes to the file.
:wq : Saves the changes and exits.
:# : Brings you to line number #
:$ : Brings you to the last line of the file
:0 : Brings you to the first line of the file
:/keyword : Search for the string "keyword" in the file. Press "n" to view the next search result.
My server disc space is growing over time because of the unknown logs somewhere in the server. Use this command to check out which folders and files consume most of the unnecessary disc space and delete them.
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'
ListBreak.com © 2018
Time is precious. If you have an alternative or better way to get this done, do let us know so that we can compose this list and help more people.