Linux Tips and Tricks – Codelivly

Related Articles

The Linux console can seem quite overwhelming for new users and even for experienced users without the knowledge of Linux tips and tricks. Linux is a very flexible operating system.
However, remembering all the instructions and how to use them is challenging. With these great tips, you can use Linux like a pro in no time!

This list of tips includes useful commands and smart hacks that are easy to forget if they are not committed to memory.

We will teach you some of these tips and tricks for Linux in this article, and you will notice a significant improvement in your productivity while working at your Linux console. so lets start.

1. Remove larger files

Files can become “heavy” due to poor management skills, and can be huge up to 250 GB! Because of the large amount of data involved, the rm function is not particularly useful in this case.

Therefore, you should avoid deleting a single log file of this size using the rm utility. You should choose an easier solution:

 > /path-to-file/huge_file.log

You will need to adjust the file names and path to suit your circumstances. As a result, for that particular file, the empty output will be created.

2. Copy in several manuals

In general, when you want to copy a file, you use a cp command that looks like this:

cp /path-to-file/my_file.txt /path-to-new-dir

right? What if you want to copy it to multiple directories? Usually you go for something like this:

cp /home/user/my_file.txt /home/user/1
cp /home/user/my_file.txt /home/user/2
cp /home/user/my_file.txt /home/user/3

It is time consuming and frustrating to write these commands over and over again. What if we told you that you could still complete this task in one command? You still do not believe us? Consider the following:

echo /home/user/1/ /home/user/2/ /home/user/3/ | xargs -n 1 cp -v /home/user/my_file.txt

Walla! Your work has been done.

3. Minimize hardships

The more keys you press on the keyboard, the longer it will take you to complete the tasks. You can greatly increase the efficiency of your work if you are aware of some time-saving commands.

To execute your last command, you must use the UNIX bash shell.

Instead of typing the entire command, press Ctrl + R and edit a few lines if necessary. This will save you a lot of time and help you complete your tasks faster.

4. Go back

Everyone knows you can upload a library using cd .. But almost no one knows it with cd - You can return to the previous directory:

5. Going home

This is probably the shortcut to your home folder. But there is a trick that only a few people are aware of: it will still send you to your home directory if you type a CD without other characters following it:

6. Search files easily

It may seem easier than you think. The following is an example of a command used to search for files:

find /home/user -type f

This command will locate all the files in the / home / user directory. This is a powerful order, however you may want to narrow it down and make it more focused.

For example, suppose you want to include the option to search for files larger than 10 MB. You can do this by:

find . -type f -size 10M

Be careful not to use the root directory, as failure may result in high system I / O.

7. Shutting down the system

Did you know that you can configure your system to shut down at a specified time using certain commands? You can be physically present or not when your computer is off, but you have control over when it is done. Use this command to set the shutdown time:

sudo shutdown 21:00

Your system will shut down at exactly 21:00! Instead of hours you can also choose minutes.
for example:

sudo shutdown +15

Your computer will shut down automatically after 15 minutes.

8. SSH authentication without a password

If you frequently log in to a particular SSH server, it can be annoying to have to enter a password every time. You can skip it if your host and server exchange credentials.

First, you need to create one. Run the command ssh-keygen. It creates a private / public key pair and saves it ~/.ssh/id_rsa. You must now copy the public key to the server with this command: ssh-copy-id [email protected]_host.The password for the server will be requested, and the public key will be copied. This system now allows you to log in to this server without a password.

Note: This method is no less secure in any way than traditional authentication. If your local system is secure, it may be even more secure. There will be no way to log in to SSH unless the private key is hacked.

9. Leave your program running in the background

If you run a program in the terminal, it will be stopped as soon as the operation of the terminal is completed. Use the nohup command, which represents “do not disconnect”, to avoid this and leave the program running.

For example, transfer files to and from the server scp, While making sure that the transfer will continue even if you accidentally close the console window, use this command:

nohup scp very-big-file.mkv :~/very-big-file.mkv

nohup Also creates a file named nohup.out To save the output of the command.

10. Answer yes

You may get annoyed if you develop bash scripts to automate specific tasks because you have to say yes to every command you run. The prefix of each command in yes | Bypass it and answer yes to every command:

yes | apt-get update

If you want to answer no Instead, precede it with yes no |.

11. Log in as root

It’s not perfect, but there are times when you have no choice. However, sudo su is the next best alternative. Su connects to you as root, and sudo executes commands as root. As a result, the root password will not be required. Furthermore, some versions prohibit root passwords, leaving you with only one option:


12. View system information

To view your system information nicely, install and use the command screenfetch:

13. Using the correct command

When you have a lot of command lines at your disposal, it’s hard to remember them all. You must not only remember the correct command, but also be able to execute it effectively.

What you are looking for is:


Just replace “description” with the description of the real command you are looking for.

Take a look at this example:

  • dir (1) – List of directory contents
  • ls (1) – List of directory contents

With this trick, you do not have to remember the required command at all. You only have to look for one!

14. Execution of multiple commands

Often, you have to wait for the previous command to complete before proceeding to the next command. It takes a lot of your time once again.

There is an effective way to do this. You can use a single command to execute multiple commands and your waiting time is over!

The command looks like this:

command_1; command_2; command_3

This separator is a life saver when it comes to finishing your work on time.

15. Multiple commands: When the first fails

Discuss how to execute multiple commands in a single command in the previous section. What should you do if the first command does not work? If the previous command succeeded, you just want to execute the next command.

For this use “||” Separator as shown below:

command_1 || command_2

Then, command 2 will only run after command 1 when you use the command in one line above.

16. Creating library trees

You typically use the mkdir command to create new libraries in Linux.

The usual directory creation command goes like this:

mkdir new_folder 

How about creating 7 subfolders within the new folder? Repeating the above command 7 times is not an ideal solution. You can instead use this command:

mkdir -p new_folder/folder_1, folder_2, folder_3, folder_4, folder_5, folder_6, folder_7 

Using the command above, you can easily create 7 subfolders without running mkdir multiple times.

17. Beyond the end or beginning of a line

Typing a command is long, but you realize you need to go back to the beginning to make some changes.

What are you doing? Press the left arrow key several times until you reach the beginning of the command?
There is a better way.

Aside from using the End and Home keys, you can select Ctrl + E to get to the end and Ctrl + A to get to the beginning.


Mastering these tips and tricks will make the transition to Linux hassle-free.

Even if you are not an expert in Linux, you should be able to understand the said commands. That’s what makes it so appealing!

These handy tricks can work wonders for your efficiency. Wishing you all the best on your journey in Linux!

Also check:



Please enter your comment!
Please enter your name here

Popular Articles