How to use basic Linux commands
This guide will teach you basic Linux (Ubuntu) commands
Once you have connected to your server via SSH, you are ready to learn the following commands.
cd
- cd is a command used to change directories, change directories is what cd stands for. An example of the cd syntax is:cd /var/www/html
this will put you in the/var/www/html
directory in your Terminal.mv
- mv is used for moving files to different directories. mv's syntax is the following:mv file.txt /home
which will movefile.txt
to/home
. If you want to change the file name, you can domv file.txt /home/newfile.txt
.ls
- ls is used to list all the directories and files in your current directory. The syntax for ls is justls
. No arguments needed.mkdir
- mkdir is used to create directories. mkdir's syntax is the following:mkdir myFolder
. A folder will be crated in your current directory named "myFolder".rm
- rm is used to remove files and directories. For files, the syntax isrm file.txt
. For folders, the syntax isrm -rf myFolder
orrm -rf myFolder/
You can also put the -rf at the end of the command.nano
- nano is used to create and edit files. nano's syntax isnano file.txt
ornano /home/file2.txt
. You can save your file by pressingCTRL + X
thenY
.cp
- cp is used to copy files to different directories. An example of cp's syntax iscp myArchive.zip /etc
. Or to rename the file,cp myArchive.zip /etc/newArchive.zip
.zip
- zip is used to create zip archives of files and/or folders. An example of the zip syntax iszip -r myArchive.zip myFile.txt anotherFile.txt
or to include directories,zip -r anotherArchive.zip myFile.txt myDirectory/
.unzip
- unzip is used to unarchive ZIP files. An example of the unzip command syntax isunzip myArchive.zip
.sudo
- sudo is used to run commands with super user permissions, and do means, do. An example of sudo syntax issudo nano /etc/protectedFile.txt
which will run the command nano with super user permissions. If you are having issues executing commands due to the lack of permissions, try putting sudo before your commands.apt
- apt is an online repository of applications and utilities. It is used to download, or remove packages from your system. An example of apt syntax issudo apt install zip
orsudo apt remove zip
.ping
- ping is used to ping other servers. An example of the ping syntax isping my-owehost-server.com
orping 95.217.93.198
.wget
- wget is used to download files from a website. An example of wget syntax isget https://my-owehost-server.com/file.txt
.curl
- curl is an alternate to wget, which also allows you to download files to your local machine from a website. An example of curl syntax iscurl -O https://my-owehost-server.com/file.txt
Last updated