Useful Linux Commands To Benefit All

Posted on

As a true GNU/Linux user I always hear things from other users beside me. Well yes, aside from the usual swearing and cursing the day the mother-board was created. I am talking about other things I hear. For example the following:

  • Repeated key strokes of “UP + ENTER”
  • Moans of "Maximum allowed open files, wtf is that? I’m confused"
  • Subtle murmuring of "Why is this always showing only in IPv6?"

It’s these things that I hear and it’s the part that no one (at least the primates I encounter in the jungle) do not have the intellectual curiosity to research if there is a better way to perform that task. So just to help a little I am going to publish my small list of most useful GNU/Linux commands to help all primates, apes and monkeys alike (I consider my self a gorilla… I have seen some yetis but they seem to know Linux and use weird things like Slackware and DSL)

Find the number of open files for a given process.
ls -al /proc/fd | wc -l

Find the number of open sockets for a given process in-case the above was under the limit.
ls -al /proc/fd | grep socket | wc -l

Increase the limit of number of open files per process, here we use 2048. Damn why would a process open 2048 files at a time? Feels like a leak….
ulimit -n 2048

Amazing magic with the watch command. Monitor a command and set an interval in second. The below command executes ls -l every 1 seconds to monitor any file changes in the directory. (wow my hand doesn’t hurt anymore)
watch -n 1 'ls -l'

View all network connections on IPv6 and IPv4, or just remove -i6 to just see IPv4.
lsof -Pnl +M -i6 -i4

Show all folders in a directory and how much space they take up and display their sizes in bytes and sort by size
du -s * | sort -g

Be a complete jerk and get the CPU usage to 100% at constant rate! šŸ™‚
ping -l 10000 -s 10 -q -f localhost

Please remember to look at the MAN pages for these commands to further customize them to your needs.

Advertisements

One thought on “Useful Linux Commands To Benefit All

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s