5 Bash for loop examples to make command line tasks more efficient

One of the things that excited me while learning Unix/Linux was how quickly one can perform tasks via the command line. Bash is a fully functional scripting language that incorporates Variables, Loops and If/Then statements; the bash shell allows a user to use these functions while performing adhoc tasks via the command line. This is also true for the other common shells such as bourne, korn shell, and csh. Below I will show 5 example for loops that are run on the command line without being placed into a shell script....

 · 6 min · Benjamin Cane

Changing the default nice value for a user or group

Recently I coveredhow to increase and decrease the CPU priority of processes using nice and renice. Today I am going to cover how to change the default niceness value for a user or group. Why change the default CPU priority value? Before explaining how to change the default niceness value, let's cover why this could be useful. Scenario #1 You have a system that has thousands of users that log in via SSH and could potentially run CPU intensive tasks....

 · 2 min · Benjamin Cane

Setting process CPU priority with nice and renice

Nice is a command in Unix and Linux operating systems that allows for the adjustment of the “Niceness” value of processes. Adjusting the “niceness” value of processes allows for setting an advised CPU priority that the kernel's scheduler will use to determine which processes get more or less CPU time. In Linux this niceness value can be ignored by the scheduler, however other Unix implementations can treat this differently. Being able to adjust the niceness value comes in handy in two scenarios usually....

 · 4 min · Benjamin Cane

Finding the OS version and Distribution in Linux

When supporting systems you have inherited or in environments that have many different OS versions and distributions of Linux. There are times when you simply don't know off hand what OS version or distribution the server you are logged into is. Luckily there is a simple way to figure that out. Ubuntu/Debian $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=13.04 DISTRIB_CODENAME=raring DISTRIB_DESCRIPTION="Ubuntu 13.04" RedHat/CentOS/Oracle Linux # cat /etc/redhat-release Red Hat Enterprise Linux Server release 5 (Tikanga) Catchall If you are looking for a quick way and don't care what the output looks like, you can simply do this as well....

 · 1 min · Benjamin Cane

Reading files in reverse with tac

Today's article is going to cover a command that falls into the “I don't use this often, but when I do it's awesome” category. The tac command is very similar to the cat command in that it is used to concatenate and print files. However there is one very large difference, the tac command does this in reverse, starting with the last line of the file and working its way up to the first line....

 · 2 min · Benjamin Cane