Sunday, March 30, 2014
ssh connection to unreachable host through a reachable host
ssh -t reachable_host ssh unreachable_host
set an audible alarm when machine comes online
ping -i 60 -a IP_address
Display top 10 running processes sorted by memory usage
ps aux | sort -nk +4 | tail
save your previous command as a script
echo "!!" > foo.sh
what is my my public ipadress ?
at 8:02 PM
Sunday, March 16, 2014
To enable logging of your sftp sessions
Replace the susbsystem line in your /etc/ssh/sshd_config with
Subsystem sftp /usr/libexec/openssh/sftp-server -f LOCAL5 -l INFO
Add the following to /etc/syslog.conf or /etc/rsyslog.conf
Restart the sshd and syslog/rsylog services,
sftp sessions should now be logged to /var/log/sftpd.log
at 5:04 PM
Wednesday, March 12, 2014
The folder /etc/profile.d/ is the recommended place to add customizations to the system profile.
do not edit /etc/profile rather add files in the /etc/profile.d folder
For example, when installing the oracle JDK, you might need to set the JAVA_HOME and JRE_HOME environment variables.
Create a new file called java.sh
Within this file, initialize the necessary environment variables
save the file.
every time you reboot the environment variable will be loaded system wide..
at 9:59 AM
Sunday, March 2, 2014
How to undelete files from ext3/ext4 partition
When you accidentally delete a file or files or an entire directory extundelete can recover them for you.
yum install extundelete
The first step should be to unmount the partition that your lost files are on, as soon as possible.
If you know the path and the name of the file or directory (let's assume it's /home/cgerada/Music/ and you accidentally deleted all your music files .
sudo to root
sudo -i or su - root and go to a partition with enough free space to store the deleted files. Then:
extundelete --restore-files /home/cgerada/Music/ /dev/sda3
you should get the following
NOTICE: Extended attributes are not restored.
WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
The partition should be unmounted to undelete any files without further data loss.
If the partition is not currently mounted, this message indicates
it was improperly unmounted, and you should run fsck before continuing.
If you decide to continue, extundelete may overwrite some of the deleted
files and make recovering those files impossible. You should unmount the
file system and check it with fsck before using extundelete.
Would you like to continue? (y/n)
Loading filesystem metadata ... 3679 groups loaded.
Loading journal descriptors ... 31276 descriptors loaded.
As soon as extundelete is finished, you will find the recovered files in the folder you were in when you ran the command /RECOVERED_FILES/
If you deleted a directory itself, you can use --restore-directory
There are some other useful options such as --restore-all , --restore-file, --after 'dtime' or --before 'dtime'
type extundelete --help to see exactly what the other options do.
at 5:29 PM