Is Apache or some other process using most of your CPU but you have no idea why? I have the solution for you! Linux has some low-level troubleshooting tools that will let you investigate the issue and find out what’s going on. One of those tools is strace, which will capture all the system calls […]
There is a number of tools you can use in Linux to see what is going on your machine at the network level, one of the most common is netstat. This command will show you all the connections on your system, including some that you may not be interested in, like UNIX sockets. There are […]
In this post you will learn about bash expansions, you probably already used them if you have done something like “ls *.txt”. Basically the shell does some processing on the command line before actually executing it, which enables us to do a number of things. Here is a small cheatsheet of the most useful expansions: […]
Here is a quick tip on how to make the output of some tools prettier, for example we can use the mount command which by default looks like this:
|
1 2 3 4 5 6 7 |
/dev/sda1 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) none on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) none on /dev type devtmpfs (rw,mode=0755) |
Using the column command with the -t option we can apply some formatting so it is more readable:
|
1 2 3 4 5 6 7 8 9 |
$ mount | column -t /dev/sda1 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) none on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) none on /dev type devtmpfs (rw,mode=0755) |
Much better, isn’t it? Man page […]
If we want to remove extra spaces in a text like this:
|
1 |
This is some interesting text. |
You could be tempted to use sed, but there is a simpler way using tr
|
1 |
tr -s ' ' |
And we end up with:
|
1 |
This is some interesting text. |
With tr you canĀ also delete characters instead of compressing them. Let’s say we wanted to get rid of the vowels. […]
