Home Linux 18 Linux Commands You Could Run In The Terminal

18 Linux Commands You Could Run In The Terminal

0

In UNIX and perhaps every Linux distribution, the most fun part is running Linux commands in the terminal. The terminal is a very important resource but then it could also be a small way to have fun with quirky commands.

In this article, we will learn fun commands, basic commands, and advanced commands. The whole lot really.

Perhaps we should start at the beginning and explain what “Linux” is. Linux is basically a free and open-source operating system. Linux systems can be modified and redistributed. Linux, an operating system’s kernel, is closely associated with UNIX, in fact, it is a clone of UNIX.

Just in case you’re wondering who created it, his name is Linus Torvald. There are different Linux distributions, some of which are listed below:

  • Fedora
  • Debian
  • Linux Mint
  • Ubuntu Linux

A terminal (or Linux shell) gets commands from users, passes it along to the OS for processing and then reveals an output. The terminal means a lot in Linux.

It is possibly the most important part. While Linux has a command-line interface “CLI”, its distributions usually come in graphical user interfaces “GUI”. Now that we’ve covered the essentials, let’s find out some fun commands and some useful ones too.

Some Basic Linux Commands That Could Prove Useful

1. pwd – The first thing you’ll come in contact with when you open the terminal is the home directory. The “pwd” command helps you know the directory you’re in, just in case you lose sight of where you entered. It will show you the absolute path from the root (also known as the base of a Linux system).

2. mkdir & rmdir – When you are trying to create a directory, it is important to use the “mkdir” command.

For example, if you want to create a directory named “Sack”, you will type ” mkdir Sack”. It is important to note however that if your directory name has two words, say maybe “Sack Letters”, the command will be “mkdir Sack\ Letters”.

mkdir Sack

Where mkdir is used to create, rmdir is used to destroy. Sounds ominous but rmdir only destroys directories, empty directories. To destroy or simply delete directories containing files, use “rm” only.

3. rm – A command used to delete both files and directories. If you want to delete only the directory, you will have to use another variant “rm -r”. Remember to specify if you want both files and directories to be deleted or just the directory.

To delete a log file named “slack”, you could use the script below:

rm slack.log

4. cp – To copy files through the command line, you must use the cp command. It follows two arguments, where you want to copy files from and their destination.

In the script below, the first file file1.txt is copied into the second file2.txt. Note that adding the extension type to the file is very important.

cp file1.txt file2.txt

5. mv – This command is similar to cp in that they follow two arguments. The difference is that instead of copying files, it moves those files through the same command file.

In cases of moving a file using the mv command, first, pass the name of the current file followed by the name of the new file. In the script below, file file1.txt is renamed to file2.txt.

mv file1.txt file2.txt

6. locate – It offers exactly what it means. Locating files in a Linux system. It is similar to the search command in Windows. If you are not sure about the name of a file or where the file is, the locate command is your best bet of finding it.

If you don’t remember if the file name started with an uppercase or lowercase letter, you are still covered. Just use the -i argument and you won’t have to worry about the case.

First, it has to be installed on the terminal using this script:

sudo apt-get install locate

Using the locate command will give you a list of files with the name you searched for. An example is if you are looking for a file named “mark”, use “locate -i mark” and you’ll get all the files containing your search term. There’s also room for two words in your search.

You just have to differentiate them using an asterisk (*). For example, the name of the file is “mark up”, the command will be “locate -i *mark*up”.

locate -i mark

7. touch – Another command that creates any type of file. Most types of files can be created easily with a command like “touch new.zip”. Other file types like txt can also be created by using the command “touch new.txt”.

touch new.txt

8. cd – The cd command takes you anywhere you want to go. It basically leads you to any directory you want.

Let’s say you’re in the home folder and you want to go to the “DIY” folder, then all you have to do is input “cd DIY” and voilà you’re there. Almost like magic, really.

cd DIY

There’s something you should be careful about though when your file has two names and you type in the command like “cd DIY Hack”, your command will be voided.

The reason is that the terminal will take the second argument as a different one and not just part of the first one. So it is important to use a backward slash like this “cd DIY\ Hack”.

cd DIY\ Hack

Another thing to note is that if you just input “cd”, you will be taken to the home directory. If you want to get back to a folder you just left, all you have to do is input “cd..”. The two dots denote moving back.

Some Fun Linux Commands That Could Prove Useful Too

While some of these commands may not be totally useful, there is some good stuff here too.

9. figlet – If you love ASCII art, then this command is absolutely perfect for you. The figlet command absolutely simplifies the whole process by transforming all the strings given automatically.

You can always add your own fonts to the preexisting ones. “figlet piglet” automatically transforms the word.

Linux Commands

Before Figlet can be used, you have to install it on Linux terminal using the script below:

sudo apt-get install figlet

10. banner – This is similar to the figlet command. The difference is that it (banner) instead displays the text associated with the command in a big banner format. It follows the same process “banner life is good”

banner try it now

11. espeak – Surely this is the beginning of a revolution, computers talking. This is all a bit over the top but it explains what this command is all about. Computers talking.

Something important to note is that whatever you type in the quotation marks after espeak is what your computer will say. For example, espeak “coronavirus is horrible”. If you’re tired of hearing the same old voices every day, you might want to try this out.

espeak "coronavirus is horrible"

12. yes – This command repeats a string until you stop it. In our everyday life, we use this word (yes) a lot for different reasons and just like in Linux command, it could be used for different purposes.

The more useful purpose will be to use it when you are running scripts that wait for prompts. If you automate it by running this command, you will save a lot of energy and time.

For example, “yes y path/to/script” shows that you’ve allowed your system to continue choosing yes when confronted with the option and that is one of the more useful uses of this command.

Another use, although a lot less useful, is just to repeat statements that sound cool.

13. rev – A command that reverses any input. It looks quite quirky cause it basically means if used, “come” will turn to emoc. That is the rev command. Another facet to it is that it can be used to reverse an entire file. “rev (put file path)”.

14. sl – Visuals on terminals or shells can be very boring so when steam locomotives at random appear, there’s a little bit of excitement than usual. sl literally means steam locomotives.

Note that before using the sl command, sl should be first installed on the terminal using this line of script:

sudo apt install sl

15. cal – If for any reason you need to view a calendar and you can’t simply check your phone as normal people do, then this command is for you.

Most people don’t realize it but calendars are a fixture of any UNIX system. Accessing it is pretty easy, just type “cal”. The current month will be displayed but you can tweak it to display the year and the month you want. There’s even this weird “-j” option that sums up the days from January 1 to the current date.

Some Advanced Linux Commands That Are Definitely Useful

16. echo – If you want to move data, especially texts, into a file, then the command “echo” is your guy. In creating a new txt file or adding to a preexisting text file, all you have to do is input “echo this global warming sucks >>new.txt”.

echo [string]
echo "this global warming sucks >>new.txt"

Normally, we would be talking about using slashes to show that there is just one argument but that’s why the triangular brackets are there. No need for the slashes.

17. cat – No, not the cute animals. It is a command that displays the contents of a file. It is commonly used to view programs with ease.

The syntaxes for this is:

cat filename OR cat > filename OR cat [options] filename

18. zip, unzip – This is quite common and it is useful in compressing files into a zip archive and extracting files from a zip archive.

unzip filename.zip
zip -r output_file.zip fileName folderName

Using the -r in the zip script allows a recurse into directories.

Note: To use this on the terminal, you must first install the package with this code:

apt-get install unzip

Conclusion

There are many important Linux commands for the terminal and this article has shown all the sides to those commands. The fun commands that just makes everything a little better, the basic commands that will make you more efficient or advanced commands you need to master to fully utilize the Linux system.

All of them are important in the long run and you might want to use some of them soon.

Please tell us in the comments section about any command you like or use frequently.

LEAVE A REPLY

Please enter your comment!
Please enter your name here