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 1-2021-30 next last

1 posted on 12/06/2021 12:15:03 PM PST by ShadowAce
[ Post Reply | Private Reply | View Replies]

To: rdb3; JosephW; martin_fierro; Still Thinking; zeugma; Vinnie; ironman; Egon; raybbr; AFreeBird; ...

2 posted on 12/06/2021 12:15:16 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack )
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

Very good primer!


3 posted on 12/06/2021 12:21:44 PM PST by frogjerk (I will not do business with fascists)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

I can also get along without electricity too. And refrigeration.


4 posted on 12/06/2021 12:23:38 PM PST by Steely Tom ([Voter Fraud] == [Civil War])
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

bkmk


5 posted on 12/06/2021 12:27:38 PM PST by sauropod (Meanie Butt Daddy - No you can't)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

I knew most of those.


6 posted on 12/06/2021 12:27:50 PM PST by Pollard (PureBlood -- youtube.com/watch?v=VXm0fkDituE)
[ Post Reply | Private Reply | To 1 | View Replies]

To: Pollard

I knew some at different times.


7 posted on 12/06/2021 12:34:11 PM PST by wally_bert (I cannot be sure for certain, but in my personal opinion I am certain that I am not sure.)
[ Post Reply | Private Reply | To 6 | View Replies]

To: ShadowAce

The terminal is only extremely useful because of The ‘Net and
Search Engines...[along with cut and paste and editing capabilities].

Jus’ sayin’...


8 posted on 12/06/2021 12:37:59 PM PST by Paladin2 (Critical Marx Theory is The SOLUTION....)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

I use Yakuake terminal. It runs all the time and when you hit F12 and it pops down from the top of the screen. I’ve got it set to be 60% of the screen width and centered horizontally. I don’t have to wonder where the terminal will open or how small it will be.


9 posted on 12/06/2021 12:40:29 PM PST by Pollard (PureBlood -- youtube.com/watch?v=VXm0fkDituE)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

For later


10 posted on 12/06/2021 12:43:43 PM PST by Fellow Traveler
[ Post Reply | Private Reply | To 2 | View Replies]

To: ShadowAce
I would just nit-pick (because I'm avoiding doing something else at the moment) that for #16 that isn't really running multiple commands "at once." It is running multiple commands in sequence from one command line entry.

Now, you can run multiple things at once by putting a running command into the background. I'm a bash guy so this is what I know:

./some_command &
./some_other_command

This will start some_command and immediately return control to the shell, where you can start some_other_command and both will run simultaneously.

A couple of other really handy tricks involves piping. Say the some_command program was going to dump a lot of text to the screen. It's going to scroll by fast...or you can pipe that into one of two programs, more or less. Yes, that is their names.

./some_command | more

The vertical bar is the pipe symbol. All the standard output from some_command gets piped into the input of the more program - which shows you a few lines at a time and allows you to page through it at your own pace. Less works similarly, no I really haven't bothered to find out why we have two nearly identical utilities.

There are also 'head' and 'tail' programs similar to more and less that, as the names imply, show you merely the head (first few lines) or tail (last few lines) of the text.

One other good trick is redirecting to a file. Suppose some_command generates a lot of text and you want to save it to look at later:

./some_command > foo.txt

Will dump the standard output of some_command into a file called foo.txt. Or you can get fancy and do:

./some_command > foo.txt
./some_other_command >> foo.txt

This puts the output of some_command into foo.txt, then it appends the output of some_other_command to foo.txt - so you can later read it all.

Ok, enough geeking out for one afternoon.

11 posted on 12/06/2021 12:53:39 PM PST by ThunderSleeps (Biden/Harris - illegitimate and everyone knows it.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: Steely Tom
My desktop

My full screen menu

Hardly primitive and I rarely use the terminal. I can do an update faster via the terminal than opening up the GUI program for it. Hit F12 to open my terminal and type sudo apt-get update and sudo apt-get upgrade

I do have one program that is command line only.

It's a video downloader that will download from youtube plus hundreds of other websites.

cd Videos takes me to my video folder and youtube-dl https://www.youtube.com/watch?v=tNcpAQPpIOE will download the best quality version of that video.

youtube-dl -F https://www.youtube.com/watch?v=tNcpAQPpIOE will list all the video only, audio only and video + audio formats available and give me 2-3 digit numeric codes for them.

youtube-dl -f 18 https://www.youtube.com/watch?v=tNcpAQPpIOE is that same highest quality as not using the argument.

Works on most any website or webpage with a video on it. All the browser addons for that are bloated and/or make you sign up to get the best quality versions.

12 posted on 12/06/2021 12:59:15 PM PST by Pollard (PureBlood -- youtube.com/watch?v=VXm0fkDituE)
[ Post Reply | Private Reply | To 4 | View Replies]

To: Pollard
I use Yakuake terminal.

I've heard of it, but have never used it.

My favorite is Terminator. I have a few layouts set up so I can click on an icon, and it will open a window separated into multiple panes and each pane will automatically log into a cluster node on a couple of different HPCs at work. One click, and I'm logged into about 20 different servers.

Pretty cool.

13 posted on 12/06/2021 12:59:19 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack )
[ Post Reply | Private Reply | To 9 | View Replies]

To: Pollard

I love youtube-dl.


14 posted on 12/06/2021 1:01:27 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack )
[ Post Reply | Private Reply | To 12 | View Replies]

To: ShadowAce

I struggle with terminal at times. Even so, I see its value and I actually prefer it for basic tasks like installing new software.


15 posted on 12/06/2021 1:12:36 PM PST by Tallguy
[ Post Reply | Private Reply | To 2 | View Replies]

To: ShadowAce

For a while, it wasn’t working for bitchute so someone created bitchute-dl which you can find on github. I think youtube-dl is working with bitchute again though. Little hard to use it on rumble but I did figure it out but don’t remember exactly what I had to do so I’d have to figure it out again. Might have used one of the Embed urls.


16 posted on 12/06/2021 1:13:17 PM PST by Pollard (PureBlood -- youtube.com/watch?v=VXm0fkDituE)
[ Post Reply | Private Reply | To 14 | View Replies]

To: ShadowAce

Why does the title say “every Ubuntu user should know”?

Is this a way if saying “every n00b should know”?

Because AFAICT none of this is unique to Ubuntu.


17 posted on 12/06/2021 1:25:11 PM PST by 2 Kool 2 Be 4-Gotten
[ Post Reply | Private Reply | To 1 | View Replies]

To: 2 Kool 2 Be 4-Gotten
I know. I use these all on Red Hat as well.

I'm guessing here, but I think the author only knows Ubuntu and thinks all other consumer-level users only use it.

18 posted on 12/06/2021 1:27:36 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack )
[ Post Reply | Private Reply | To 17 | View Replies]

To: ShadowAce

Exactly.


19 posted on 12/06/2021 1:29:57 PM PST by 2 Kool 2 Be 4-Gotten
[ Post Reply | Private Reply | To 18 | View Replies]

To: ShadowAce

Oh man... Another “Too techy for you” Linux post. My friend... Are you trying to discourage the use of Linux when there are now full point and click GUI desktops?

Here is a counter argument to terminal “Dependency”...

Aside from the totally capable GUI interfaces most distros have now, I am running into very useful apps but they have no GUI Icon launch access supplied, only terminal commands to start them. Found that it is easy to create a launch shortcut and icon that will automatically perform the launch command for you without needing to put the commands in the terminal. I am going to use Cinnamon as the example but in the link below are the instructions how to do it with other desktops.

For Cinnamon, Xfce, And LXDE, first find and make note of where the launch file for the application is located in your directory. You can find this with a search of your directory using the application name. Or it can usually be found in system files/user/bin/. Or just use the terminal launch command supplied with the app if you have it.

You can then create an application launcher by right-clicking on the desktop background, and selecting +Create Launcher menu. Click on the Create Short cut icon and it will give you a menu of icon types to choose from. Then fill in the app type, app name, terminal command, the location of the app in your file directory using the “Browse” dropdown menu, and then any additional note you want as meta data when you hover your mouse cursor over the icon.


20 posted on 12/06/2021 2:20:07 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 1 | View Replies]


Navigation: use the links below to view more comments.
first 1-2021-30 next 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