Useful Linux commands for SysAdmins and DevOps
This is a work in progress list of all my SysAdmin/DevOps commands for Linux that can be useful for beginners in this area. Usually, all server management work must be done straight in the Linux terminal.
Mounting/unmounting external disks
A lot of beginner Linux users doesn't know how to mount an external disk (like a flash drive or a USB HDD) from the CLI. The process is surprisingly straightforward and simple.
First, connect your external disk and track its id with the following command:
Your new unit should appear as
/dev/sdb or something like that. In order to mount the first partition of that unit, you should reference it like
Now create a new local folder in
/media in order to mount
/dev/sdb1 in your PC:
mkdir -p /media/extdrive
Now, let's mount the drive:
mount /dev/sdb1 /media/extdrive
You can read/write in your drive through the folder
/media/extdrive. After all operations are completed, unmount the drive and delete the mountpoint:
umount /media/extdrive rm -rf /media/extdrive
The proper way to copy big files
cp can easily copy small files. But here at work we had to backup big Virtual Machine partition images (around 160GB each) and we had no control of the copy progress. Let's suppose that we have the following VM images in our current directory:
productionServer.img productionServer-1.img productionServer-2.img
In order to copy them into our mounted external drive in a single command, we just can do:
rsync -WP productionServer*.img /media/extdrive
rsync -WP command will show the progress and remaining time of all our copied files.
Some basic XenServer commands
The XenServer Management Service allows the creation and maintenance of Virtual Machines (VMs for short). Let's suppose that the VMs are created in the server and we just have to maintain them. In order to see a list of running machines, just run:
sudo xm list
Suspend and Unsuspend commands stop the execution of a VM and saves its state on disk (like Hibernation on Windows). To suspend/unsuspend a VM called
productionServer (useful for manual backups), just run:
sudo xm suspend productionServer sudo xm resume productionServer
I hope this can help somebody!