Best X

50 Basic Ubuntu Terminal Commands and Shortcuts for Linux Beginners

Ubuntu terminal commands are the basic necessity and the first step of learning to navigate Ubuntu commands. Suppose you are a beginner in Linux or plan to use Linux terminal commands regularly. In that case, we present to you the utmost comprehensive and illustrated guide to 50 basic ubuntu terminal commands and shortcuts for anyone enthusiastic enough to prepare scripts and daily tasks through Ubuntu Linux commands.

But before we step into the vast world of Linux terminal commands, it is a severe impediment to not learn about Ubuntu as the best user-friendly Linux distros out there.

Reasons for learning Ubuntu Terminal Commands and Shortcuts

Free and open-source Ubuntu is used by millions of people. It’s also an ethos, a collaborative endeavor, and a most importantly, a community. Since Ubuntu’s regularly updated kernel is based on Linux, it allows millions of users to run free and open software on various devices. Developed in 2004 by Mark Shuttleworth, Ubuntu quickly became the most popular Linux operating system, with its ever-increasing support for numerous open-sourced software and driver solutions for multiple hardware. Ubuntu has the largest Linux application store while developing support for Windows-based applications, steam games, video editing, etc.

Ubuntu terminal commands and shortcuts intro

While learning Linux, the first OS that comes into everyone’s mind is Ubuntu. Ubuntu is easy to understand, and its flexibility and simplistic yet powerful nature attract a lot of Linux enthusiasts towards Ubuntu terminal commands. This is mainly owing to Ubuntu’s strong shell, which is at the heart of all Linux versions. An intuitive “Terminal” interface lets you interact with this shell by issuing any number of commands.

The default terminal used by Ubuntu is based on BASH (Bourne-Again Shell), which is the case for most Linux-based distros. This BASH programming layer understands and evaluates Ubuntu terminal commands, and users can execute productive tiresome tasks within a few seconds by writing precise Linux terminal commands. BASH commands are highly confusing for newcomers, but they don’t have to learn every Linux terminal commands that exist out there unless you want to perform every task in Ubuntu through the Linux terminal.

Unlike the command prompt in Windows and macOS, we require an apt knowledge of Linux terminal commands for the maximum utilization of resources. All you need to know are some fundamental Ubuntu terminal commands that allow you to perform manageable tasks, most of which will be covered in this article.

The article has been divided into 2 parts. The first section will represent 50 Ubuntu terminal commands and their corresponding working code included within the description in the following fashion:

$ Your_code_will_be_written_here

Copy the portion of code after the $ sign, which resembles the Ubuntu commands.

The second part will also list some basic shortcuts usable with the Ubuntu Linux terminal, which is crucial in the code management in Ubuntu’s coding platform. Corresponding screenshots for each command will also be added, resembling the output for every command segment.

Abbreviations used in this article

Here are some of the standard codes used with most commands and abbreviations used for illustration

  • sudosudo is used at the beginning of any command that requires superuser access or administrative privileges. It is similar to the “Run as Administrator” option in the context menu of any executable file in Windows. Sudo is required to modify any system files or perform any action requiring access to the root partition. After using a command with sudo, users must enter their administrator password and press Enter for confirmation.
  • <package-name>, <destination>, <source> – These pieces of command have to be replaced with real names, which serves the purpose as written between < and >. For example, <source> will be replaced by the source file’s name, <destination> by the path of the destination folder, and likewise.

50 Basic Ubuntu Terminal Commands and Shortcuts

1. apt / apt-get

Advanced package tool or APT is a Linux package manager handling installation and removal of software in Ubuntu. APT automates the retrieval, setup, and installation of software packages on Unix-like computer systems, either from precompiled files or by compiling source code called repositories.

A stable internet connection is required for downloading packages from multiple repositories and upgrading the existing ones. Here are Ubuntu terminal commands with which apt or apt-get can be used:

  • $ sudo apt-get update – This update command is used to resynchronize package index files with their sources, and the available package lists are retrieved from the /etc/apt/sources.list location. Upgradeable package lists are updated from the web, but it is not implemented on the system yet. The command basically shows which software can be upgraded.

Ubuntu terminal commands and shortcuts apt-get update

  • $ sudo apt-get upgrade – These Ubuntu terminal commands facilitate downloading the newer versions of the system plus user packages. The installation of the available updates proceeds simultaneously after retrieving packages from the web, and a confirmation asks if you have the necessary space for updating. Specify a package name after the above command to upgrade the software separately.

Ubuntu terminal commands and shortcuts apt-get upgrade

  • $ sudo apt-get install <package-name> – A single software can be downloaded and installed separately using the above command and typing the required package name. The wrong package name will result in an error.

Ubuntu terminal commands and shortcuts apt-get install

  • $ sudo apt-get remove <package-name> – We can uninstall any software package via the remove Ubuntu terminal commands. Use $ dpkg – list to return the list of packages already installed on the device, and type that with remove.

Ubuntu terminal commands and shortcuts apt-get remove

  • $ sudo apt-get purge <package-name> – Such purge command willingly removes the complete existence of the software and performs the uninstall operation much harshly.

Ubuntu terminal commands and shortcuts apt-get purge

  • $ sudo apt-get autoremove – Helps remove unnecessary packages installed as dependencies in the up-gradation process.

Ubuntu terminal commands and shortcuts apt-get autoremove

2. ls

Usage – $ ls -l

Ubuntu terminal commands and shortcuts ls

ls stands for list. The ls Ubuntu terminal commands display the contents of the current working directory’s files and folders. This is going to be one of the most useful Linux commands you’ll ever learn. As you can see in the preceding screenshot, using the Ubuntu commands without any parameters results in a list of all the files and folders in the directory. The command provides a great deal of freedom regarding how the data is shown in the output.

3. pwd

Usage – $ pwd

Ubuntu terminal commands and shortcuts pwd

pwd stands for Print Work Directory. You can print the current working directory on your terminal with the pwd command. It’s a simple command that accomplishes its goal admirably. In most cases, your terminal prompt should already include the entire directory. However, if it doesn’t, here is a swift command to see what directory you’re in. Another use for this command is when writing scripts, when it may be used to locate the directory where the script was saved.

4. cd

Usage – $ cd <directory path>

Ubuntu terminal commands and shortcuts cd

cd or Change Directory or chdir is one of the basic Ubuntu terminal commands used in other operating systems. Moving around inside directories is almost a need while working in the terminal. The cd command is an essential Linux command to know since it allows you to traverse across folders. Simply enter cd, then directory, as seen below.

Any full path of a directory can be entered after the cd command. Here are some common ways to navigate directory levels with cd:

  • $ cd /    – Advances you to the root level.
  • $ cd ..   – Proceeds up one level of the current directory.
  • $ cd -   – Goes back to the previous directory.

5. mkdir

Usage – $ mkdir <folder1> <folder2> <folder3>

Ubuntu terminal commands and shortcuts mkdir

mkdir stands for Make Directory. You may create directories from the terminal with the mkdir command. mkdir, followed by the directory name, is the default syntax for creating new empty folders in the filesystem.

In the screenshot above, we created a new folder using the command $ mkdir new1. Multiple folders can also be made by providing different names in the same line separated by space. Nested folders can be created using the following syntax

$ mkdir -p /<folder1>/<folder2>/<folder3>

6. cp and mv

The cp and mv Ubuntu commands are similar to the copy-paste and the cut-paste operations in Windows, respectively. Since the rename operation is not implemented by Ubuntu terminal commands but needs its support, the mv command ideally helps change the names of files and folders.

Usage – $ cp <source> <destination>

If <destination> is a filename, it creates copy of <source> at the same location. Here <destination> can also be a path to a folder, and so can <source>.

Ubuntu terminal commands and shortcuts cp

In this screenshot, $ cp Sample Sample-Copy creates another file called Sample-Copy. Let us use mv in the same manner.

Usage – $ mv <source> <destination>

Ubuntu terminal commands and shortcuts mv

The mv Ubuntu terminal commands cut the original file given in position and get pasted as a new file with the name <destination>. Thus this operation resembles the renaming functionality, as the older file gets deleted and a similar copy with a new name is created in the same directory.

7. rm

Usage:

$ rm <file name>

$ rm -r <folder/directory name>

Ubuntu terminal commands and shortcuts rm

rm stands for remove. rm is used to remove files, folders, or entire directories. rm is very powerful while performing removal tasks and is one of the important Ubuntu Terminal commands you should know. While deleting a directory, rm requires the argument -r beside it. We also need to use sudo for deleting any system root file or directory.

8. touch

Usage – $ touch <file name>

Ubuntu terminal commands and shortcuts touch

touch is one of the standard Ubuntu Linux commands used to create any kind of file in the current working directory. touch command creates files devoid of any content and thus can be used when beginners don’t have any data to store at the file creation time.

touch can also be used to create multiple files simultaneously by providing their names successively followed by a space.

9. history

Usage – $ history

Ubuntu terminal commands and shortcuts history

history is one of the most powerful and useful Ubuntu terminal commands. It shows the list of commands that have been used recently in the Ubuntu terminal, and by default, the history command can display the last 500 commands executed by you. The list is also accessible through the .bash_history file in the home directory.

After the list is displayed, you can use the up and down arrows to navigate through the entire list and remember what you did yesterday.

10. echo

Usage – $ echo <Anything written here>

Ubuntu terminal commands and shortcuts echo

echo command is the best tool for displaying any line of text or string that the user writes after the echo command. Such Ubuntu terminal commands are beneficial while writing scripts or batch files that output something to the Linux terminal.

The strings written after echo can be redirected to any file as an input via the redirection operator.

11. cat

Usage – $ cat <file name>

Ubuntu terminal commands and shortcuts cat

cat outshines its usage as one of the most frequently used Ubuntu terminal commands. The command displays the entire content of a specified file and can also help create, concatenate, and redirect the output of multiple files together in the Ubuntu terminal.

12. df

Usage – $ df

Ubuntu terminal commands and shortcuts df

df, also known as Disk Free, is a handy utility command which displays valuable information about a file system’s total and available space. Such noteworthy Ubuntu terminal commands show the storage system for every disk supported by Ubuntu. The FileSystem argument gives the name of the device on which the file system is mounted, the directory on which the file system is mounted, or a file system’s relative pathname.

13. du

Usage – $ du

Ubuntu terminal commands and shortcuts du

The du (Disk Usage) command is one of the standard Ubuntu Terminal commands that quickly displays disc utilization information. It works best with particular folders and has many options for customizing the output to fit your requirements. The user can use a variety of parameters or flags, as with other commands. Individual files or sub-directories can be included as an argument at the side of the du command which outputs their own disk usage.

14. clear

Usage – $ clear

The clear Ubuntu command helps clear every line of codes and outputs present in the current terminal screen and allows the user to start typing on a new board. Such helpful Ubuntu terminal commands clear the clutter on the terminal screen and helps you in focusing on your current work.

15. man

Usage – $ man <command name>

Ubuntu terminal commands and shortcuts man

In Linux, the man command displays the user manual for any command executable on the terminal. NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS, and SEE ALSO are all included in the detailed view of the command. man helps users in remembering how a particular command can be used and various complexities associated with it. Such informative Ubuntu terminal commands display the Manpage that comes pre-downloaded with every Linux software package.

16. uname

Usage – $ uname -a

Ubuntu terminal commands and shortcuts uname

‘UNIX name’ is abbreviated as Uname. The uname command is used to show basic operating system and hardware information. uname prints kernel information and system architecture when given parameters. All Linux and Unix-like operating systems support the Uname command. The parameter -a stands for all and shows every information about the system. Omitting this parameter will simply display Linux as output.

17. top

Usage – $ top

Ubuntu terminal commands and shortcuts top

The top Ubuntu terminal commands show a running system in real-time. This application is quite similar to the task manager of the Windows OS but does not have a GUI. It can provide system statistics and a list of processes or threads that the Linux kernel is presently managing. The sorts of system summary information presented and the types, order, and amount of information displayed for processes may be customized by the user. This configuration can be saved between restarts. The application has two interactive interfaces: process manipulation and personal setup, covering every element of its functioning.

18. info

Usage – $ info <command name>

Ubuntu terminal commands and shortcuts info

info is another handy tool for learning more about Linux commands. info is a program that reads documents in the info format (a special format generated usually from a Texinfo source). In most cases, info pages provide more technical information about a command than the command’s corresponding man pages. Navigation and connections between pages are also possible using information.

19. -h or –help argument

Usage – $ <Command name> -h or $ <Command name> – help

Ubuntu terminal commands and shortcuts – help

Whenever the -h parameter is attached to any Ubuntu terminal commands, a short and precise description of the command is displayed, which is highly helpful in overviewing all the command-line options on short notice.

20. whoami

Usage – $ whoami

Ubuntu terminal commands and shortcuts whoami

The whoami command outputs the effective user ID’s user name, as its name implies. In other words, it shows the name of the user who is presently logged in.

21. tar

Usage –

For compressing files,

$ tar -cvf <archive name> <files seperated by space>

Ubuntu terminal commands and shortcuts tar compress

For extracting files,

$ tar -xvf <archive name>

Ubuntu terminal commands and shortcuts tar decompress

In Linux, the tar command is used to generate and extract archived files. Using the tar command, we may extract several archive files. The compressed files created using the tar Ubuntu Terminal commands ends with the .tar extension. The -c argument is used to create an archive, and multiple files can be added in the same line. The -x parameter is used to extract files from the compressed file into the current working directory.

22. zip and unzip

Usage – 

$ zip <archive name> <file names separated by space>

Ubuntu terminal commands and shortcuts zip

$ unzip <archive name>

Ubuntu terminal commands and shortcuts unzip

The zip and unzip Ubuntu terminal commands offer a more straightforward approach to compressing and extracting files. They don’t use arguments like the tar command and perform the task very swiftly. They ask for a confirmation before replacing an already existing file, whereas tar doesn’t.

23. ln

Usage – $ ln -s <source path> <link name>

Ubuntu terminal commands and shortcuts ln

The ln command is one of the standard Ubuntu Terminal commands for creating a hard link (symlink) to an existing file or directory. Since a hard link connects to the inode of a particular file, the contents of which are saved on disc, several filenames can be linked with the same file. On the other hand, symbolic links are individual files that use the -s parameter to refer to other files by name.

24. wget

Usage – 

$ wget <link to file>

$ wget -c <link to file>

Ubuntu terminal commands and shortcuts wget

The wget command is one of the most helpful command-line programs for downloading files from within the terminal. When working with source files, this is one of the most crucial Ubuntu commands to know.

When you specify a download link, it must be a direct link to the file. If the wget program cannot access the file due to a faulty connection, it will download a website in HTML instead of the actual file. Combining the command with the -c parameter, we are able to resume uninterrupted downloads, but the chunk of the downloaded file is unchecked for errors.

25. mount and unmount

Usage – 

$ mount <device path> <mount directory>

$ unmount <device path>

In a Linux filesystem, all files are organized into a large tree with the root at /. These files can be distributed across several devices based on your partition table; your parent directory is initially mounted (i.e., attached) to this tree at /. Other devices can be mounted manually using the GUI interface (if provided) or the mount command.

The mount command is used to mount a device’s filesystem to a large tree structure (a Linux filesystem) rooted at /. On the other hand, the umount command may be used to unmount these devices from the tree. These Ubuntu terminal commands identify the device path from the /dev folder and creates a link to it in the current filesystem tree.

26. chmod

Usage – 

$ chmod +rwx <filename> to add permissions.

$ chmod -rwx <directoryname> to remove permissions

Ubuntu terminal commands and shortcuts chmod

Have you ever wanted to edit a file in Linux, but you don’t have the necessary permissions? Ubuntu terminal commands like chmod is very influential in such problematic situations. The chmod command lets you alter a file’s permissions using a symbolic or numeric mode, as well as a reference file. As arguments, the command can take one or more files and/or folders separated by spaces. A file’s permissions can only be changed by root, the file owner, or a user with sudo capabilities. When using chmod, be highly cautious, significantly if you’re altering permissions recursively.

27. chown

Usage – $ chown <owner name>:<group name> <file name>

Ubuntu terminal commands and shortcuts chown

Changing the permissions of files and folders is something you’ll have to do from time to time while using Ubuntu terminal commands. The chown command in Linux allows you to change file and directory permissions as needed. This is useful for setting features and services, for example. chown works by modifying the ownership of the file or folder to a different owner, and the change can be verified by using the command ls -l

28. cal

Usage – $cal <month> <year>

Ubuntu terminal commands and shortcuts cal

cal is the command to use if you want a fast glance at the calendar in the Linux terminal. The cal command outputs the current month calendar by default. The cal Ubuntu terminal commands utilize the terminal space to get a neat and precise view of the calendar for a single month or the entire year. Although it is practically unadvisable to use this Ubuntu command, the well-presented calendar display serves as enjoyment for Ubuntu Linux commands enthusiasts.

29. alias

Usage – $ alias <new name> = <original command>

Ubuntu terminal commands and shortcuts alias

Do you have any commands that you use on the terminal regularly, and you absolutely hate typing it again and again? It might be rm -r or ls -l, or something more complicated like tar -xvzf. This is one of the most essential Ubuntu Terminal commands to know if you want to significantly boost your productivity and scripting speed.

If you have a command that you use frequently, it’s time to make an alias for it. What exactly is an alias? Simply put, it’s another name for a command you’ve created. 

Now, if you type lsl or rmd in the terminal, you’ll get the same output you would have obtained if you had used the complete commands.

30. dd

Usage – $ dd if = <path to/name of input file> of = <path to/name of output file>

Primarily dd stood for Disk Dump and served the glorious purpose of converting and copying files from one file system to another. On Unix, device drivers and particular device files appear under filesystems as regular files. dd performs read-write operations on these files, and as a result, dd may be used to do things like backing up a hard drive’s boot sector, creating bootable flash drives, creating valuable mirror images, and restoring from it as well. The dd Ubuntu terminal commands may also execute conversions on the data as it’s being copied, such as byte order shifting and text encoding conversions to and from ASCII and EBCDIC.

31. whereis

Usage – $ whereis <command name>

Ubuntu terminal commands and shortcuts whereis

Have you ever looked at a specific command from most Ubuntu terminal commands and wondered where the CLI program is stored and where the informative description about it is generated? whereis is such peculiar Ubuntu commands that locate the binary, source, and documentation files for the provided command name. Leading pathname components and any (single) trailing extension ending in ext are removed from the provided terms. whereis then tries to discover the required application in the usual Linux locations and the locations provided by $PATH and $MANPATH.

32. whatis

Usage – $ whatis <command name>

Ubuntu terminal commands and shortcuts whatis

Contrary to the above, these informative Linux terminal commands visualize the function of the supplied command. A brief summary is given on each manual page of Ubuntu terminal commands. whatis examines the manual page names for any name that matches and shows the manual page descriptions for the matched command’s name. The mandb software updates the index databases, which are utilized throughout the search.

33. ufw

Usage – $ ufw <option> <port or web address>

Every Linux-based distro out there has a built-in firewall preventing viruses and malicious software into our system. Some of the essential firewall tools that come with Linux distributions can be used to customize them. iptables is one of the Ubuntu terminal commands used as the default firewall tool in Linux. ufw, or Uncomplicated Firewall, is an iptables interface designed to make the procedure easier. For novices, it might be tough to understand how to correctly configure a firewall with iptables, even though the program is robust and adaptable. ufw may be the option for you if you’re unsure which technology to employ to secure your network.

34. useradd and adduser

Usage – 

$ sudo useradd <user name> -d <user directory path>

$ sudo adduser <user name>

Ubuntu terminal commands and shortcuts adduser

Ubuntu is a multi-user operating system, much like any other Linux distribution. For many command-line and GUI programs, each user might have varying permission levels and unique settings. One of the fundamental abilities a Linux user should have is the ability to add and delete users.

Ubuntu terminal commands like useradd and adduser don’t fail to satisfy us while performing the function of adding users. The useradd command provides a low-level utility and is quite challenging to be used by beginners in Linux terminal commands. The adduser command provides a friendly front-end interface that asks a series of questions from the user that helps build the account body.

35. usermod

Usage – $ sudo usermod <user name> <options>

Ubuntu terminal commands like usermod changes or updates any properties of a previously established user account. In rare cases, an administrator may need to alter the login name, the user’s home folder, or the password expiration date of a user who has already been established. Here’s when the usermod command comes in handy.

We must have an existing user account to run the usermod command, and the command can only be used by the root (superuser). When using the usermod command to modify the user’s name, UID, or home folder, you must also ensure that the modified user is not actively running any processes.

36. passwd

Usage – $ sudo passwd <user name>

Ubuntu terminal commands and shortcuts passwd

Passwords for user accounts can be changed with the passwd command. A typical user can only change their own password, but a superuser can change the password of any account. The account or password validity period can also be changed with passwd. If the user has an old password, they will be asked for it first. This password is then encrypted and compared to the password that has been saved. Second, the age of the password is verified if the user is allowed to change it at this time. Lastly, after being asked for a new password twice, a complexity test is performed, after which the password is changed successfully.

37. ssh

Usage – $ ssh <username> @ <hostname>

ssh (SSH client) is one of the Ubuntu terminal commands that allows you to log into a remote system and run multiple commands on it. Its purpose is to enable safe encrypted communications over an unsecured network between two untrusted sites. The secure channel may also forward X11 connections, arbitrary TCP ports, and UNIX-domain sockets. ssh establishes a connection to and logs into the provided destination, which can be [user@]hostname or a URL of the type ssh://[user@]hostname[:port]. It is impediment that the user provide their identity to the remote machine using one of several methods.

38. exit

Usage – $ exit

After we finish working on scripts and coding inside the Ubuntu terminal, we must close all instances of the terminal and the processes running inside itThe exit Ubuntu terminal commands force the terminal window to conclude, and the terminal service is terminated successfully.

Basic Ubuntu Terminal Shortcuts

Ubuntu Terminal Shortcuts are the perfect accompaniment to the Ubuntu terminal commands, and it is indispensable to learn these shortcuts to be fluent in Ubuntu commands. The + symbol between individual keys denotes that all the keys must be pressed together from left to right.

39. Ctrl + Shift + T

This shortcut creates a new tab inside the current terminal window, which is entirely blank and has no connection to the previous terminal.

40. Ctrl + Shift + W 

This shortcut eliminates the current tab you are working all. All the services are still running even if the terminal is closed unexpectedly.

41. Ctrl + A 

Transfers the cursor or the blinking dot to the beginning of the current command line being written.

42. Ctrl + E 

Transfers the cursor to the end of the current line

43. Ctrl + U 

This shortcut erases the Ubuntu terminal commands that have been written freshly on a new line.

44. Ctrl + R 

This shortcut combination is advantageous, as pressing these create a field using which we can search the history for previous Ubuntu terminal commands that have been typed.

45. Ctrl + C 

When we forcefully need to terminate a recursive application or script, the best method for stopping is pressing this Ubuntu terminal shortcut. Any activity is prevented from continuing, and resources held by the hanged processes are immediately released.

46. Ctrl + Z 

This shortcut works similarly to the previous one but doesn’t kill processes as harshly as the former. Instead of terminating directly, the shortcut sends a SIGSTOP to the running process, and such an approach is much softer but doesn’t work on frozen or endlessly recursive processes.

47. Ctrl + L 

Clearing screens can be performed in a jiffy with this handy shortcut key combination. It serves the action of the clear Ubuntu terminal commands and executes it very swiftly.

48. Ctrl + Shift + C 

This shortcut combination copies the selected or highlighted content of the text in the terminal to the temporary memory or the clipboard. Such copied text can be pasted anywhere using the basic shortcuts.

49. Ctrl + Shift + V  

Suppose you see some useful Ubuntu terminal commands on the web and want to try it out on the terminal, the usual copy-paste shortcut won’t work, as Ubuntu fails to recognize it. Use this shortcut to paste the code into the terminal from any external source, and the formatting will be merged.

50. TAB 

Upon pressing the TAB key anywhere, it automatically finds the nearest code and auto-completes the command or filename you were typing. If multiple names are present in the same directory, press TAB again to scroll through the available choices. It can also out a list of possible combinations if the list is too large.

Conclusion

All the given Ubuntu terminal commands and shortcuts help make your Linux learning a bit easier, and it is always convenient to have a list of commands handy to focus more on the given task. These Ubuntu terminal commands are applicable in Ubuntu and other Linux distros, and you can try such hands shortcuts to perform out there.

Feel free to comment below and let us know how this article improved your Linux learning experience and mention any necessary changes required. Cheers!!

Rohan Maji

An enthusiastic technical learner, a helping troubleshooter, adept at content writing, a passionate gamer and interested to provide hassle free solutions for technical difficulties.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button