SnapShooter Backups Server, Database, Application and Laravel Backups - Get fully protected with SnapShooter

SSH Basics Part 3: Useful commands

This is part 3 of SSH Basics. In this tutorial, we will introduce some of most common yet useful commands we have found.

Server admin weapons

Until now, you should be comfortable with SSH.∂You know how to setup SSH key pairs, and you know how to login to any Linux servers using SSH. Once you have SSH to a server. Most of time, you will find yourself doing a lot of server administration tasks in a black box. Knowing the basic commands and make yourself comfortable with them will make your life much easier as a server administrator.

In this tutorial, we will introduce some of most common yet useful commands we have found. These commands are like secret weapons for you, so make sure you understand each one of them. Now let's get started!

List of useful commands

cd is a command for changing directory.

cd /path/to/destination-directory
cd ~ # change to home directory of current user

cp is a command for copying files and directories.

cp /path/to/source-filename /path/to/destination-filename
cp /path/to/source-filename /path/to/destination-folder/ # copy to destination folder,keep the same file name

mv is a command for moving files and directories.

mv /path/to/source-filename /path/to/destination-filename # this will rename the file
mv /path/to/source-filename /path/to/destination-folder/ # move to destination folder, keep the same file name
mv /path/to/source-filename . # move to current directory

touch is a command for updating the access date and / or modification date of a file or directory. It will create an empty file if it does not exist. It is very handy for creating a file.

touch filename.txt # create filename.txt file if it does not exist yet

ln is a command for making links between files.

ln -s /path/to/source-filename /path/to/destination-filename
ln -s /path/to/source-filename . # create a link ./source-filename pointing to /path/to/source-filename

head is a command for reading the first few lines of any text given to it as an input.

head filename.txt

tail is a command for displaying the tail end of a text file or piped data.

tail filename.txt
tail -f filename.txt #displays the lines and then monitors the file

chmod is a command for changing the access permissions to files and directories.

chmod 777 filename.txt

chown is a command for changing the owner of a file.

chown root filename.txt # change the owner of filename.txt to 'root'
chown root:root filename.txt # change the owner of filename.txt  to 'root' and the group identifier to 'root'.

ls is a command for listing files of a directory.

ls -l ~ # listing files of home directory of the user in long format

ps is a command for viewing the processes running on the system.

ps aux # show all processes for all users.

The end

This is the end of SSH Basics series , we hope you find this series useful. If you like our post, please follow us on Twitter and help spread the word. We need your support to continue. If you have questions or find our mistakes in above tutorial, do leave a comment below to let us know.