Category:
1. How to unmount the unresponsive media drive
First, simulate it. Stick a disk in your CD/DVD drive, open up a terminal, and mount the CD/DVD drive.
If your system automatically mount, then you can skip the mounting part.
root@server:~# mount /media/cdrom root@server:~# cd /media/cdrom root@server:~# while [ 1 ]; do echo "All your drives are belong to us!"; sleep 30; done
Now lets open up a second terminal and try to eject the media drive:
root@server:~# ejectYou'll get a message like:
umount: /media/cdrom: device is busy
Before you free it, let's find out which process is using it.
root@server:~# fuser /media/cdrom
You will see the process that being accessing the CD/DVD drive.
Now as a root, you can exercise your godlike powers and kill processes:
root@server:~# fuser -k /media/cdrom
The above command will kill all processes that using /media/cdrom. Now we can safely eject the media
root@server:~# eject 2. How to get your screen back when it's hosed
When we working on some text files, sometime we might accidentally open a binary file. Try this:
root@server:~# cat /bin/cat
Behold! Your terminal looks like garbage. Everything you type looks like you're looking into the Matrix.
So, usually we will close the terminal and open a new one. But, actually there is command that will "clear" the screen.
root@server:~# resetNow your screen is back to normal. This is much better than closing the window and then logging in again, especially if you just went through five machines to SSH to this machine.
3. How to change hostname
In Debian / Ubuntu, you can change the hostname using the following method.
root@server:~# echo "SERVER_FQDN" > /etc/hostname
In Red Hat / CentOs, you need to edit/set HOSTNAME in /etc/sysconfig/network file
HOSTNAME=SERVER_FQDNThe server’s hostname will be updated after a reboot.
4. How to disable sending an email after a cronjob is completed
By default, cron jobs send an email to the user account executing the cronjob. If this is not needed put the following command at the end of the cron job line:
> /dev/null 2>&1
5. How can i ping a block of hosts?
If you have the fping command installed on your machine you can ping to a specific block of hosts. Just include the -g switch in the command:
root@server:~# fping -g 192.168.0.1/24 192.168.0.1 is alive 192.168.0.2 is alive 192.168.0.3 is unreachable
6. How to remove files names begin with a dash ( - ) character?
rm ./-filename
Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command.
Add new comment