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 move file.txt to /home. If you want to change the file name, you can do mv 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 just ls. 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 is rm file.txt. For folders, the syntax is rm -rf myFolder or rm -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 is nano file.txt or nano /home/file2.txt. You can save your file by pressing CTRL + X then Y.

  • cp - cp is used to copy files to different directories. An example of cp's syntax is cp 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 is zip -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 is unzip myArchive.zip.

  • sudo - sudo is used to run commands with super user permissions, and do means, do. An example of sudo syntax is sudo 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 is sudo apt install zip or sudo apt remove zip.

  • ping - ping is used to ping other servers. An example of the ping syntax is ping my-owehost-server.com or ping 95.217.93.198.

  • wget - wget is used to download files from a website. An example of wget syntax is get 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 is curl -O https://my-owehost-server.com/file.txt

Last updated