Sunday, March 30, 2014
Command line shortcuts
Clear screen
cntrl l
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 ?
curl ifconfig.me
Sunday, March 16, 2014
Enable Logging for SFTP sessions
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
#sftp logging
local5.* /var/log/sftpd.log
Restart the sshd and syslog/rsylog services,
sftp sessions should now be logged to /var/log/sftpd.log
Wednesday, March 12, 2014
setting persistant system wide environment variables
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
vim /etc/profile.d/java.sh
Within this file, initialize the necessary environment variables
export JRE_HOME=/usr/java/jdk1.7/jre
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/usr/java/jdk1.7
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
save the file.
every time you reboot the environment variable will be loaded system wide..
Sunday, March 2, 2014
Undeleting Files that were accidentallly deleted
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:
type
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)
type y
y
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.
Subscribe to:
Posts (Atom)