Ubuntu is one of the most customizable Linux distributions available today. Almost all Linux enthusiasts start with Ubuntu. And if you’re new to Ubuntu, then check out this list of basic commands that will help you get acquainted with the system.
The commands will help you to perform some basic actions in the operating system. To help you get off to a good start, here are the top 18 basic Ubuntu commands for beginners.
The 18 Basic Ubuntu Commands Every Beginner Needs to Learn
The sudo (SuperUser DO) command allows you to run programs or other commands with administrative privileges, just like “Run as administrator” on Windows. Elr is useful when, for example, you need to modify files in a directory that your user would not normally have access to.
The apt-get is one of the most important commands of Ubuntu, and that every beginner should know. It is used to install, update and remove any package. apt-get basically works on a database of available packages. Here is the list of different apt-get commands:
- sudo apt-get update
apt-get update with administrator privileges is the first command you need to run on any Linux system after a fresh install. This command updates the database and informs your system whether there are newer packages available or not.
- sudo apt-get upgrade
After updating the package database, the next step is to update the installed packages. To update all packages with available updates, you can use this command.
And if you like to update a particular package, you should tweak the above command a bit:
sudo apt-get upgrade package name . Replace the package name with the desired package.
- sudo apt-get install
If you know the package name, you can easily install a program using this command:
sudo apt-get install package name . Replace the package name with the desired package.
If you’re not sure what the package name is, you can type a few letters and press the tab and it will suggest all available packages with those letters, thanks to the autocomplete feature.
The ls (list) command lists all files and folders in your current working directory. You can also specify paths to other directories if you want to see their contents.
The cd (change director) command , also known as chdir, used to change the current working directory. It is one of the most used basic commands in Ubuntu. Using this command is easy, just type cd followed by the folder name. You can use full paths to folders or simply the name of a folder within the directory you are currently working on. Some common uses are:
- cd / – Takes you to the root directory.
- cd .. – Takes you to a directory level.
- cd – – Takes you to the previous directory.
Here are some examples of how to use the cd command in Ubuntu:
Example 1: cd home – open the home folder in the current directory.
Example 2: cd Linux Drive – open the Linux Drive folder in the directory.
The pwd (print working directory) command displays the full path of the current working directory.
The cp (copy) command allows you to copy a file. You must specify both the file you want to copy and the location you want to copy it to – for example, cp xyz / home / myfiles copies the file “ xyz ” to the directory “/ home / myfiles “ .
The mv (move) command allows you to move files. You can also rename files, moving them to the directory they are currently in, but with a new name. Usage is the same as cp-f or example mv xyz /home/ myfiles would move the file “ xyz ” to the directory “/home/ myfiles “ .
The rm (remove) command removes the specified file.
- rmdir (“remove directory”) – Removes an empty directory.
- rm -r (“recursively remove”) – Removes a directory along with its contents.
The mkdir (make directory) command allows you to create a new directory. You can specify where you want the directory to be created – if you don’t, it will be created in your current working directory.
The history command displays all your previous commands, up to the history limit.
The df (display filesystem) command displays disk space usage information for all mounted file systems.
The du (directory usage) command displays the size of a directory and all its subdirectories.
This command displays the amount of free space available on the system.
14. uname -a
The uname -a – command provides a wide range of basic information about the system.
The top command displays processes using the most system resources at any time. “Q” can be used to exit.
The man command displays a ” man page”. The man pages are generally very detailed, and it is recommended that you read the man pages for any commands you are not familiar with. Some uses are:
- man man – Provides information about the manual itself.
- man intro – Displays a brief introduction to Linux commands.
Similar to man, but generally provides more detailed or accurate information.
18. command name> -h or command name> -help
This command is a third alternative for getting help. While not as detailed as the information or manual pages, this will provide a quick overview of the command and its uses.
htop not comes by default with Ubuntu Linux, so first you need to install using following command
sudo apt install htop
htop, a cross-platform interactive process viewer. It is a text-mode application (for console or X terminals) and requires ncurses.
Neofetch ; A command-line system information tool written in bash 3.2+ also not comes by default in Ubuntu, so you need to install using following command
sudo apt install neofetch
To make your skill even easier, these Ubuntu keyboard shortcuts can help.
|Ctrl + Shift + T||Open new tab in current terminal|
|Ctrl + Shift + W||close current tab|
|Ctrl + A||Move cursor to beginning of line|
|Ctrl + E||Move cursor to end of line|
|Ctrl + U||Clear all current line|
|Ctrl + K||Clears cursor right command|
|Ctrl + W||Delete the word before the cursor|
|Ctrl + R||Allows you to search your history for commands that match what you typed|
|Ctrl + C||Copy current process|
|Ctrl + Z||Suspend the current process by sending the SIGSTOP signal|
|Ctrl + L||Clean the terminal output|
|Alt+F||forward a word|
|Alt + B||back one word|
|Ctrl + Shift + C||Copy highlighted command to clipboard|
|Ctrl + Shift + V or Shift + Insert||Paste the contents of the clipboard|
|Up/Down arrow keys||To scroll through the command history, allowing you to quickly run the same command multiple times|
|TAB||Used to complete the command you are typing. If more than one command is possible, you can press it multiple times to cycle through possible conclusions. If a very large number of commands is possible, it can display a list of all possible conclusions.|