Wednesday, 28 July 2010

Linux tips

User name maybe 32 characters maximum

Find all files older than 10 days in /var/backup folder and delete them, excluding folders /var/backup/server1 and /var/backup/servers/server2
find /var/backup \( -path '/var/backup/server1' -o -path '/var/backup/servers/server2' \) -prune -o -mtime +10 -exec rm {} \;

Change file creation date to 11 days ago
touch -d "11 days ago" filename

Show GID of user, that runs a process 
ps -eo uid,gid,args

Show detailed information about software raid array
mdadm --detail /dev/md1

When was the last reboot?
root#server:/#last reboot

Create list of directories in tar archive
tar -ztvf file.tar.gz | grep "^d" | awk '{ print $6}' | sort | uniq

Clone a partition table fast
sfdisk -d /dev/sda > partition.txt

Edit the text file to match the other disk (in this example /dev/sdb).
sfdisk /dev/sdb < partition.txt

Remount filesystem for writing
mount -o remount,rw /

Back for reading
mount -o remount,ro /
 
Add route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth1
ip route add 192.168.1.0/24 via 192.168.1.1 dev eth1


Add proxy server temporally
export http_proxy=http://127.0.0.1:3128/

Add proxy server persistently
echo "export http_proxy=http://127.0.0.1:3128/" >> /etc/profile

No comments:

Post a Comment

Ping does not work

Today I would like to discuss a banal situation: host A is directly connected to host B, ping from host A to host B does not work. What are...