This article will explain and provide more information on basic SSH commands to start administrating your server via SSH. Here you will find just a fraction of the available SSH commands, however, they are most commonly used.
Shows all the files and directories that are in the directory you are in.
Shows all the files and directories and more information about every file:
Shows all the files that ends with ".html":
Shows full path to the directory you are in.
Go into/change the directory into a different one.
Brings you back into the home directory:
Changes the directory into /var inside the server:
Go one step back out of the directory:
Go one step further into the directory (directory above):
Shows the content of the chosen file.
Shows the content of the "index.html" file:
Used to change the privileges of the users/groups to the file.Examples:
No one will have privileges to access "config.html" file:
Only this user can use the file and others do not have privileges for it:
The file is accessible for everyone:
chmod 777 config.html
Changes the owner of the file or group.
Changes the file's "config.php" owner into root:
Changes the owner of the "config.php" and group to root privileges:
chown root.root config.php
The same as "cat" command, but also shows the end of the file.
Shows the last 20 lines of the file /var/log/messages:
Shows the last 100 lines:
Works the same way as "cat", but shows only as much text as fits to the window.
Shows only that part of text that fits to the window opened. For
entering another page, need to press "SPACE" bar on the keyboard. For
escaping, need to press "q":
Simple file editor.
Opens up the "index.html" file for editing:
Shows who is connected to the server right now.
Shows the most relevant information on server resources in real time (RAM, uptime, top processes and others).
Creates an empty file.
Created a file "contacts.html" in directory "/home/useris/public_html/":
Creates a directory.
Creates the directory "/photos:
Copies the file's "index.html" content into the file "index2.html" when they are on the same directory:
cp index.html index2.html
Copies all the files from "/public_html/test/" directory into "/public_html" (one directory lower):
cp -a /home/useris/public_html/test/* /home/useris/public_html/
Moves the files to another directory. Usage is similar to "cp" command.
Removes/deletes the files.
Removes the "index2.html" file:
Deletes the "index2.html" file without asking if you really want to remove it ("force"):
Removes all the files that ends in ".html":
Clears the window of SSH console.
Exits the SSH console and disconnects from the user.
Used to create file archive or extract files from it.Examples:
Extract the file:
tar -zxvf file.tar.gz
Extract the file:
Collects all the files in the "test/" directory and moves it into "test.tar" archive:
tar -cf test.tar test/
Unzips the specific file:
gzip -d file.gz
Shows last 50 used commands
Downloads files from the provided internet link.