DEV Community

Cover image for Simple Commands in Linux That Will Make You Feel Like a Pro
Mark Vassilevskiy
Mark Vassilevskiy

Posted on • Updated on

Simple Commands in Linux That Will Make You Feel Like a Pro

Linux is a very popular and interesting operating system (OS), especially for programmers. The Linux terminal is a very important part of a Linux OS. That means that if you know the basic commands to enter the terminal, you'll be more comfortable and confident in using this OS.
There is so much information about Linux and so many courses. But almost no one can give you a shortlist of the most popular and useful commands except for the already well-known ones like ls and cd. I use some of these commands myself, and I can't imagine the programmer's life without them.


1. Touch

Touch is one of the easiest commands that will help you to create a new empty file (you can also create a bunch of files) in the directory that you're currently in.

touch file.txt
Enter fullscreen mode Exit fullscreen mode

Image description

2. Killall

If you have a slow PC or just want to kill all running processes that are interfering with your work, use this command:

killall Notes
Enter fullscreen mode Exit fullscreen mode

But you should remember that it deletes any data and won't let any application save it. By default, the killall command is case-sensitive. But you can use the -I option to ignore the case.

killall -I notes
Enter fullscreen mode Exit fullscreen mode

3. Tc

Using the traffic control command, you can manipulate network traffic inside your Linux OS. A common example where tc is used is in applying some packet delay to a network connection. With tc you can manipulate incoming and outgoing packets to apply things like delay or even drop a certain number of them entirely. Let's take a look at a relatively simple example where we apply a delay to our own network connection. That's my ping at Google:

pi@raspberry:~ $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=13.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=10.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=15.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=13.8 ms
Enter fullscreen mode Exit fullscreen mode

Let's induce 100ms of delay with tc:

sudo tc qdisc add dev eth0 root netem delay 100mspi@raspberry:~ $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=110 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=116 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=119 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=113 ms
Enter fullscreen mode Exit fullscreen mode

4. Fc

Suppose you want to edit a really long command that you just fired. Using the terminal will need some effort. The fc command solves this problem.

In the below example, I ran a curl command that had a typo. So I ran the fc command. The previous command, curl , opened in an editor; I fixed the command and saved the file. And the curl command ran again with the results.

5. Whiptail

whiptail is the command that creates a wonderful pop-up message. This is a handy single-purpose utility for displaying dialog boxes right inside of the terminal.

whiptail --yesno "Did you already know whiptail?" 40 150
Enter fullscreen mode Exit fullscreen mode

Image description

whiptailhas a wide range of different displays and inputs for you to choose from:

  • Message boxes
  • Text input boxes
  • Password input boxes
  • Yes or no choices
  • Checklists

6. Uname

uname gets the Linux version-related information about the operating system we're currently using. You can use -s , -r , -v , -n so that the terminal shows you exactly what you were looking for.

uname -s
Enter fullscreen mode Exit fullscreen mode

Image description

7. shred

How do you usually delete files? Do you use rm? If there was any sensitive data in that file, you may want to think twice about using rm for that sort of thing. This is where shred comes in. This little utility will actually erase a file securely by writing random data over top of the file multiple times.

shred -u file.txt
Enter fullscreen mode Exit fullscreen mode

8. Ps

ps displays information about a selection of the active processes.

ps -A
Enter fullscreen mode Exit fullscreen mode

Image description

9. Echo

echo displays a line of text or whatever you want in your terminal (just like a print function).

echo -e "Geeks \vfor \vGeeks"
Enter fullscreen mode Exit fullscreen mode

Image description

10. Sl

sl is one of the funniest commands, which is why I saved it for last.

brew install sl
Enter fullscreen mode Exit fullscreen mode

You'll get something like this:

Image description

Now type sl -F and see it fly.


Conclusion

Thanks for reading my article. Linux has a lot of different commands. However, I tried to find the ten best and most handy ones that will make you a pro at using the OS. Hope these commands will make using the OS a more pleasant experience for you.

Top comments (1)

Collapse
 
jonrandy profile image
Jon Randy 🎖️

touch will create a new file, but that is merely a convenient side effect, and not its primary purpose. The purpose of touch is to update the access and/or modification date of a file