Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

19 Absolute Simple Things About Linux Terminal Every Ubuntu User Should Know
Its FOSS ^ | 5 December 2021 | Abhishek Prakash

Posted on 12/06/2021 12:15:03 PM PST by ShadowAce

Terminal often intimidates new users. However, once you get to know it, you gradually start liking it. Well, that happens with most Linux users.

Even if you are using Ubuntu as a desktop system, you may have to enter the terminal at times. New users are often clueless about many things. Some knowledge of basic Linux commands always helps in such cases but this article is not about that.

This article focuses on explaining small, basic and often ignored things about using the terminal. This should help new Ubuntu desktop users to know the terminal and use it with slightly more efficiency.

ubuntu terminal basic tips

The terminal you see is just one of the various terminal applications available. After all terminal is just a GUI tool that gives you access to a shell where you can run the commands.

Different terminal applications (properly called terminal emulators) look different, have slightly different functions and features (like different keyboard shortcuts, color combination, fonts etc).

This article is specifically focused on the default Ubuntu terminal which is an implementation of the GNOME terminal.

1. Open the terminal with keyboard shortcut

You can open the terminal in Ubuntu by looking for it in the system menu. However, my favorite way is to use the Ctrl+Alt+T keyboard shortcut in Ubuntu.

Ctrl+Alt+T

2. Terminal vs shell vs prompt vs command line

Before you see anything else, you should know the difference between different terminologies that are often (incorrectly) used interchangeably.

linux terminal introduction

Terminal is the graphical application that runs a shell by default.

Shell is difficult to visualize separately from the terminal. The terminal is running a shell, usually Bash shell by default in Ubuntu. Like terminals, there are various shells as well. Bash is the most popular of them all and default shell on most Linux distributions.

The commands you type is interpreted by the shell. Often people think that screen they see in the terminal is the shell. That’s fine for understanding.

Prompt is what you see before the space where you type the commands. There is no set standard for the prompt. In some old terminals, you would just have a blinking cursor to the place where you can type the commands. In Ubuntu terminal, prompt gives you some information which you’ll see in detail in the later sections of this article.

Command line is not something specific to Linux. Every operating system has a command line interface. Many programming languages have command line interface. It’s a term used for the interface where you can run and execute commands.

3. Understanding the prompt

You know it by now. What you see before the space where you type the command is called prompt. It is configurable and looks different in different distributions, terminal applications and shells.

Ubuntu terminal has configured the prompt to show you a few things. You can get the following information at a glance:

A few more things you may wonder about.

The colon (:) in the prompt is a separator to distinguish between hostname and the current location.

Tilde (~) means the home directory of the present user.

For normal users, the prompt ends with dollar ($) symbol. For the root user, it ends with pound or hash (#) symbol. And hence the joke that pound is stronger than dollar.

understanding prompt ubuntu terminal

Did you notice that when I switched to the root user, the command prompt looked different without any colors? This is another reminder that prompt is not a standard and is configured explicitly. For normal users, Ubuntu has a different configuration of the prompt than the root.

Simple information like this helps indirectly. In a multi-user environment, you can easily figure out which user you are using right now and if it is a root user. The displayed location is also helpful.

learning prompt ubuntu terminal

4. Directory and files

Two terms you hear the most in Linux are directory and files.

You probably know what a file is but you may get confused with the term ‘directory’. Directory is nothing but folder. It keeps files and folders inside it.

You can go inside the directories but you cannot enter files. You can read files of course.

directory files linux

You can use the term ‘folder’ for directory and it should be fine. However, it is better to use ‘directory’ because this is what you’ll see referenced in various tutorials, documents etc. You’ll even find commands like rmdir, mkdir hinting that they deal with directories.

Additional note: Everything is a file in Linux. Even directory is a special kind of file that has the memory address of files and directories inside it. I have explained it in my article on hard links. You may refer to that if you want to know more on this topic.

5. Path: Absolute and relative

The directory structure in Linux resembles the root of a tree. Everything starts at root and spreads out from there.

If you have to access a file or directory, you need to tell how to reach its location by providing its ‘path’. This path that is composed of directory names and separators (/). If a path starts with / (i.e., root), it is an absolute path otherwise it is a relative path.

path linux

The absolute path starts from the root and can be easily referenced from anywhere in the system. The relative path depends upon your current location in the directory structure.

absolute vs relative path linux

If you are in the location /home/abhishek which has a directory named scripts containing a file my_script.sh and you want the path for this file, its absolute path will be:

/home/abhishek/scripts/my_script.sh

Its relative path will be:

scripts/my_script.sh

If you change the location, the absolute path of the file remains the same. However, the relative path changes because it is relative to your current path.

absolute relative path real examples

6. . and ..

You may often come across . and .. notation while using the Linux terminal.

Single dot (.) means the current directory.

Double dots (..) mean the parent directory (one directory above the current location).

You’ll often use the double dot (..) in relative path or for changing directory. Single dot (.) is also used in relative path but more importantly, you can use it in the commands for specifying the current locations.

use of single and double dot in linux

7. Understand the command structure

A typical Linux command consists of a command name followed by options and arguments.

command [options] argument

Option, as the name suggests, are optional. When used, they might change the output based on their properties.

For example, the cat command is used for viewing files. You can add the option -n and it will display line numbers as well.

Options are not standardized. Usually, they are used as single letter with single dash (-). They may also have two dashes (–) and a word.

Same options may have different meaning in a different command. If you use -n with head command, you specify the number of lines you want to see, not the lines with numbers.

command structure example

In command documentations, if you see something between brackets ([]), it indicates that the contents of the bracket are optional.

Similarly, arguments are also not standardized. Some commands expect filenames as argument and some may expect directory name or a regular expression.

8. Getting help

As you start using commands, you may remember some of the options of frequently used commands but it is simply not possible for you to remember all the options of any command.

Why? Because a single command may have more than ten or twenty options.

So, what do you do when you cannot recall all the options? You take help. And with help, I do not mean asking a question in It’s FOSS Linux forum. I ask to use the help option of the command.

Every standard Linux command has a quick help page that can be accessed with -h or –help or both.

command_name -h

It gives you a quick glimpse of the command syntax, common options with their meaning and in some cases, command examples.

cat command help page

If you need more help, you can refer to the manpage i.e. manual of a command:

man command_name

It goes in all of details and could be overwhelming to read and understand. Alternatively, you can always search on the internet for ‘examples of xyz commands in Linux’.

9. Linux is case-sensitive

Linux is case-sensitive. Everything you type in the terminal is case-sensitive. If you do not take that into account, you’ll often run into bash: command not found or file not found errors.

In the home directory, you have all the folders name starting with the upper case. If you have to switch to the Documents directory, you have to keep the first letter as D and not d. Otherwise, the terminal will complain.

linux is case sensitive

You can have two separate files named file.txt and File.txt because for Linux, file and File are not the same.

10. Running shell scripts

You can run a shell script by specifying the shell:

bash script.sh

Or you can execute the shell script like this:

./script.sh

The second one will only work when the file has execute permission. More on Linux file permission here.

run bash script

11. Use tab completion instead of typing it all

The Ubuntu terminal is pre-configured with tab completion. This means that if you start writing something in the terminal and then hit tab, it tries to automatically complete it or provide options if there are more than one possible matches.

It works for both commands as well arguments and filenames.

tab completion ubuntu

This saves a great ton of time because you don’t have to write everything completely.

12. Ctrl+C and Ctrl+V is not for copy pasting in terminal

Ctrl+C, Ctrl+V might be the ‘universal’ keyboard shortcuts for copy paste but it doesn’t work in the Linux terminal.

Linux inherits a lot of stuff from UNIX and in UNIX, Ctrl+C was used for stopping a running process.

Since the Ctrl+C was already taken for stopping a command or process, it cannot be used for copy-paste anymore.

13. You can surely copy paste in the terminal

Don’t worry. You can still copy paste in the terminal. Again, there is no fixed rule for the copy-paste keyboard shortcuts because it depends on the terminal application you are using or the configuration you have in place.

In Ubuntu terminal, the default keyboard shortcut for copy is Ctrl+Shift+C and for paste, it is Ctrl+Shift+V.

You can use Ctrl+C to copy text and commands from outside the terminal (like a web browser) and paste it using Ctrl+Shift+V. Similarly, you can highlight the text and use Ctrl+Shift+C to copy the text from the terminal and paste it to an editor or other applications using Ctrl+V.

14. Avoid using Ctrl+S in the terminal

Another common mistake beginners do is to use the ‘universal’ Ctrl+S keyboard shortcut for save. If you use Ctrl+S in the terminal, your terminal ‘freezes’.

This is coming from the legacy computing where there was no scope of scrolling back up. Hence, if there were lots of output lines, Ctrl+S was used for stopping the screen so that text on the screen could be read.

You can unfreeze your terminal with Ctrl+Q. But again, avoid using Ctrl+S in the terminal.

15. Pay attention to $ and <> in command examples

If you are referring to some online tutorial or documentation, you’ll see some command examples with text inside <>. This indicates that you need to replace the content along with < and > with a suitable value.

For example, if you see a command like this:

grep -i <search_term> <file_name>

You should replace the <search_term> and <file_name> with the respective actual values.

It is and indication that the command is just an example and you have to complete it with actual values.

Another thing to note here is that some tutorials show command examples that start with $ like this:

dollar symbol at the beginning of command

This is a way for them to indicate that it is command (not command output). But many new Linux users copy the preceding $ along with the actual command and when they paste it in the terminal, it throws error obviously.

So, when you are copying some command, don’t copy the $ if it is there at the beginning. You should also avoid copying random commands for random websites specially when you do not understand what it does.

Since you are reading about copying commands, when you see commands in multiple lines together, you should copy one line at a time and run them on by one:

avoid copying multiple commands

The next section tells you how to run multiple commands in one go.

16. You can run multiple commands at once

You can run multiple commands at once without user intervention. You might have seen it already as an Ubuntu user in the form of this command:

sudo apt update && sudo apt upgrade

There are three different ways to combine commands in the terminal:

;Command 1 ; Command 2Run command 1 first and then command 2
&&Command 1 && Command 2Run command 2 only if command 1 ends sucessfully
||Command 1 || Command 2Run command 2 only if command 1 fails

17. Stop a running Linux command

If a Linux command is running in the foreground, i.e., it is showing output or you cannot enter any other command, you can stop it using the Ctrl+C keys.

I discussed it previously. It comes from the legacy computing days of UNIX.

So, the next time you see a command like top or ping running continuously and you want the terminal control back, just use these two keys:

Ctrl+C
stop running program linux

18. Clear the terminal

When I find that my screen is too cluttered with different kind of output, I clear the terminal screen before starting some other work. It just a habit but I find it helpful.

To clear the terminal, use the command

clear

You may also use Ctrl+L terminal shortcut.

19. Exiting the terminal

In a few cases, I have seen people closing the terminal application to exit the session. You could do that but the proper way to exit a terminal is to use the exit command:

exit

You may also use the keyboard shortcut Ctrl+D for Ubuntu terminal.

Conclusion

There are so many additional stuff you can do in the terminal even if you are new to the entire terminal thing. You can:

And if you are looking for more, take a look at these Linux command tips and use the terminal like a pro.

Honestly speaking, there is way too much to talk about. It is difficult to determine what should be considered as absolute basics and what should be left out. For example, I wanted to avoid including the information about paths because it needs detailed explanation but going too much in detail on a single could be overwhelming.

I have passed the stage where small things used to baffle me in the terminal. If you are new to the Linux terminal or if you remember the struggle from your initial Linux days, feel free to suggest any additions to the list. I might update the list with your input.

And if you learned something new, please do mention it in the comments. I would like to see if this article was worth the effort :)


TOPICS: Computers/Internet
KEYWORDS: linux
Navigation: use the links below to view more comments.
first previous 1-2021-30 last
To: Openurmind

https://www.xmodulo.com/create-desktop- ... linux.html


21 posted on 12/06/2021 2:21:19 PM PST by Openurmind (The ultimate test of a moral society is the kind of world it leaves to its children. ~ D. Bonhoeffer)
[ Post Reply | Private Reply | To 20 | View Replies]

To: frogjerk

No needed anymore for the average non-techy user...


22 posted on 12/06/2021 2:23:18 PM PST by Openurmind (The ultimate test of a moral society is the kind of world it leaves to its children. ~ D. Bonhoeffer)
[ Post Reply | Private Reply | To 3 | View Replies]

To: ShadowAce

We have a Linux mainframe. It’s basically all I do sometimes. crontab -e


23 posted on 12/06/2021 2:25:26 PM PST by AppyPappy (Biden told Al Roker "America is back". Unfortunately, he meant back to the 1970's)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce
Thanks. How much does regex correspond to this?

Meanwhile, how many Windows users have even run dxdiag in the Run command?

24 posted on 12/06/2021 3:09:47 PM PST by daniel1212 ( Turn to the Lord Jesus as a damned+destitute sinner, trust Him to save + be baptized + follow Him!)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

Excellent post.


25 posted on 12/06/2021 6:18:19 PM PST by kiryandil (China Joe and Paycheck Hunter - the Chink in America's defenses)
[ Post Reply | Private Reply | To 1 | View Replies]

To: Nailbiter

flr


26 posted on 12/06/2021 6:22:35 PM PST by Nailbiter
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

I use a Linux app called “easystroke” (horrible name lol), and I have the terminal set to open with a mouse gesture (a “lesser than” symbol <) makes it super quick to open, and the “greater than” symbol > for close)

Another easy tip is that if you type a long command with something wrongmin it, and you get an error, instead of typing the whole,thing over again, use your “up arrow”,to select the previous command you typed, then use your left arrow to move the cursor to the right spot to correct the mistake (which is usually just a wrong letter, or symbol or somethjng)


27 posted on 12/07/2021 8:20:41 AM PST by Bob434
[ Post Reply | Private Reply | To 1 | View Replies]

To: Bob434

Oh and 6ou can scroll through previously typed commands using the up and down arrows too, incase you have to run a command a few times- makes it much easier than all the typing.


28 posted on 12/07/2021 8:23:58 AM PST by Bob434
[ Post Reply | Private Reply | To 27 | View Replies]

To: Bob434

Rather than scrolling, if you know a keyword in your command, do a Ctrl-R, and it will search for it as you start typing.


29 posted on 12/07/2021 9:39:37 AM PST by ShadowAce (Linux - The Ultimate Windows Service Pack )
[ Post Reply | Private Reply | To 28 | View Replies]

To: ShadowAce

Thanks didn’t know that. I only know a very few of the basics. Fortunately I don’t have to use terminal much, but every now and again I have to


30 posted on 12/07/2021 9:46:31 AM PST by Bob434
[ Post Reply | Private Reply | To 29 | View Replies]


Navigation: use the links below to view more comments.
first previous 1-2021-30 last

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson