There are many scripts available to quickly convert uppercase file names to lowercase but not too many to convert content of a file from uppercase to lowercase or lowercase to uppercase.
Here is how to convert from upper to lowercase:
$ tr '[:upper:]' '[:lower:]' < input_file.txt > output_file.txt
To convert from lowercase to uppercase:
$ tr '[:lower:]' '[:upper:]' < input_file.txt > output_file.txt
Done!
Very often I run into issues where a remote server has high resource usage and at the same time I attempt to log in to run the top command to get an idea what process is the culprit.
If you’ve been in this situation, you know that logging onto a server while it’s down to it’s knees is almost impossible. With the amount of time it takes to login and then run top interactively, chances are you’ll never get to see what’s going on real-time.
That’s why it’s highly recommended that you monitor your servers on regular basis and have some sort of alerting mechanism notifying you of load issues whenever they’re happening. In this article, we’re going to discuss a very simple way of doing that without logging into server manually.
To login to server1 using SSH and display all processes non-interactively:
$ ssh user@server1 'top -b -n 1'
To display only the top portion of the table detailing number of tasks, load average, cpu, memory and swap usage:
$ ssh user@server1 'top -b -n 1 | head -5'
To display processes that belong to user apache:
$ ssh user@server1 'top -u apache -b -n 1'
To monitor your remote hosts, you can put a quick script together and run via your cron every x minutes and compile daily report of overall usage. Of course it’s given that you should setup password-less ssh session so you don’t get prompted to enter a password.
You might be asking yourself…on a Linux platform, once you delete a file, it’s gone forever. The answer is yes and no. If someone wanted to retrieve those deleted files, it can still be done by using high level recoverable methods and commercial techniques.
Here are some tools which can be used to delete files on your system securely and safely.
SRM – Secure RM is a command-line compatible rm(1) which destroys file contents before unlinking. The goal is to provide drop in security for users who wish to prevent command line recovery of deleted information, even if the machine is compromised.
srm is ideal for personal computers or workstations with Internet connections. It can help prevent malicious users from breaking in and undeleting personal files, such as old emails. It’s also useful for permanently removing files from expensive media. For example, cleaning your diary off the zip disk you’re using to send vacation pictures to Uncle Lou. Because it uses the exact same options as rm(1), srm is simple to use. Just subsitute it for rm whenever you want to destroy files, rather than just unlinking them.
Wipe – Wipe repeatedly writes special patterns to the file or files to be destroyed, using the fsync() call and/or the O_SYNC bit to force disk access, in order to lessen the chance of data recovery using techniques such as magnetic force microscopy.
Shred – a command line encryption tool. The Xffm file manager uses this program to encrypt and decrypt files upon user request. The application is also used to shred files before deleting.
The binary ‘shred’ should already be installed on your distribution so no need to look further for it. Just type shred –help to get started.
As System Admins, we’ve seen it all and occaissionally we get to see a zombie process or two or three or bunch! What is a Zombie process anyway? Here is a technical description of it followed by mellowed down admin level description of it…
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the (now zombie) process to read its exit status.
The term zombie process derives from the common definition of zombie—an undead person. In the term’s colorful metaphor, the child process has died but has not yet been reaped. Also, unlike normal processes, the kill command has no effect on a zombie process.
Re-read the last sentence there…a zombie process cannot be killed! Some claim that it can be and luckily I’ve been able to kill a few myself, however, for the most part they’re impossible to kill and the only thing that clears that up from the process table is actually rebooting your system.
If you would like to try killing them first, try out the following quickies:
# kill -9 `ps aux | awk '{ print $8 " " $2 }' | grep -w Z`
# ps aux | awk ‘{ print $8 ” ” $2 }’ | grep ‘Z’ |awk ‘{print $2}’ |xargs kill -9
If that don’t do it, then leave it alone. Zombie processes do not consume resources. However, they do get annoying if they continue to grow in the process stable so at the point, just reboot the server!
I came across this question, asking myself every once in awhile when ordering new hardware. How many disks are needed to setup a server with RAID 5 configuration?
Here is a visual of how many you need….

The minimum is 3 but it’s recommended to get 4 disks of similar size/type and the 4th one can be used for parity.
If you’re like me, you probably have lots of text files stored in your home directory containing sensitive data such as passwords and notes. Many times, home directories are exposed to other users that intentionally snooping around for that sort of data.
Well, have no fear! You can simply use gpg to encrypt / decrypt on the fly:
$ gpg -c my_passwords.txt
Enter passphrase that you can remember to dencrypt with again. This’ll also generate a file called my_passwords.txt.gpg so go ahead and delete the original my_passwords.txt!
Now you’re ready to view/edit the file again. Run the following command to decrypt:
$ gpg my_passwords.txt.gpg
Enter your passphrase to generate my_passwords.txt file. Now simply use your favorite editor to view/edit the file.
In this how to, we’ll give a quick step by step instructions on how to extract ISO CD images in your Linux operating systems. In case you only need a single file or a set of files from an ISO, you can do so as well by avoiding to install the entire thing on your system.
To mount:
$ sudo mkdir /mnt/iso
$ sudo mount -o loop image.iso /mnt/iso
If the above mount option fails, try:
$ sudo mount -o loop -t iso9660 filename.iso /mnt/iso
That’s it! Just go into /mnt/iso folder and browse all files. If you need to copy a single file out, simply do:
$ cp /mnt/iso/key.txt ~
The above will copy key.txt to your home folder.
We all know how to get the cpu and memory details from our Linux servers. However, I recently found myself looking for the actual model as well as serial number of one of our remote Linux servers. Not wanting to travel to data center, I started looking for commands that would give me the type of info I was looking for (i.e HP DL360).
So I came across the command dmidecode. Simply type the following as root to get your system’s model type:
# dmidecode -t system
SMBIOS 2.3 present.
Handle 0x0100, DMI type 1, 25 bytes.
System Information
Manufacturer: HP
Product Name: ProLiant DL380 G4
Version: Not Specified
Serial Number: XXXXXXXXXXX
UUID: XXXXXXX-XXXXX-XXXXXXX-XXXXXXXX-XXXXXXXX
Wake-up Type: Power Switch
Handle 0x2000, DMI type 32, 11 bytes.
System Boot Information
Status: No errors detected
As you can see above, I’ve X’d out the Serial # and UUID to protect the identify of the server. The rest simply states what you’re looking for…HP DL380 G4.
The following is what you can use with exchange for ‘system’ with a -t argument:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
So to find out, the memory allocation per slot just type dmidecode -t memory.
According to the chattr man page…chattr changes file attributes on a Linux second extended file system. So in addition to the usual chown/chmod etc. commands, the permissions you apply to a file or directory using chattr is not visible unless lsattr is command is used.
Applying chattr against certain files on the system can be very helpful such as locking down the /etc/shadow file or other configuration files.
To make file httpd.conf write protected so no one can modify it, type the command:
chattr +i /etc/httpd/conf/httpd.conf
The above command will not allow anyone including root to write to it, modify it and even delete it from the system. In order for root to write to it, it would have to use chattr again to remove the read-only flag.
To remove the read only and allow writes, type:
chattr -i /etc/httpd/conf/httpd.conf
Peace.
I’ve always had a tough time figuring how to console in using a Linux box to other servers such as another Linux box, Sun server or a Cisco device. Having a background of Sun, the command tip -9600 /dev/cua/b or tip hardwire is embedded in my brain. But whenever I want to quickly console in from a Linux box, I start scratching my head a bit.
Well here it is…in this article I’ve listed several methods to use a serial console on Linux.
By the far the easiest way is to simply type the following:
screen /dev/ttyS0
If the above fails for some reason, add the following line to your /etc/inittab file:
S0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt102
Then, once again type:
screen /dev/ttyS0 115200
You can also use minicom if the above fails. If you don’t have it, install it via yum install minicom or apt-get install minicom depending on what Linux platform you’re on. Once you have it installed, type minicom. Then select the port, speed and /dev/ttyS0 as COM1. Save the configuration file and you’re set.