A small repository of the most common shell commands

By: Hossein Jalali • May 8, 2016

For some reason I always forget all the ssh commands quite quickly and find myself search Google and opening up the same URL over and over again.

Today I am writting all the important ones I have used and re-used all together (some gathered from previous posts), as a repository for myself and others. 

For mac users it is as easy as just openning terminal, while PC users will need to use a solution such as putty to work in a terminal view.

Below are some important instructions you need to know when on a server:

  • Connecting to the server: ssh username@server(address or IP) for first time connect you need to accept saving the chain and then place password.
  • To view the files inside a current directory type: dir
  • To move into a director type: cd foldername you can also go into multi folders by cd foldername/secondfolder
  • To move one folder back type: cd ..
  • To zip a folder: zip -r filename.zip foldername
  • To unzip a zip file: unzip filename.zip
  • To create a new folder: mkdir foldername
  • To delete a folder and files inside: rm -rf foldername/
  • To delete a file: rm filename.ext
  • To move a file from one folder to another: mv filename.ext newfoldername/
  • To set permissions to a folder and the files inside it: chmod -R 777 folder (777 giving full access to the folder and the files, which is not good practice and can reduce security)
  • To paste something you have copied with ctrl+c just right click no need for ctrl+v
  • To make apache owner of a directory and the directories/files inside it: chown -r apache:apache foldername
  • To copy files from server A to server B (considering we are logged inside server A): scp /path/to/file username@SERVERB:/path/to/destination

I will continue to add to this list as I require more functions but the above should be good enough to do about anything you have been doing slowly through ftp.

Filed Under: ssh shell linux server

comments powered by Disqus