Linux tips

add remove program from boot order?
To remove a program from boot in the ubuntu run the command:
update-rc.d -f program_name remove
To add again run the command:
update-rc.d -f program_name default
Get the disk uuid?
To get the partitions uuid use the blkid, tune2fs and lshw commands:
blkid or blkid /dev/sda1
tune2fs -l /dev/sdb1
lshw -class disk
ls -la /dev/disk/by-uuid
Find a open prgram using a socket or port?
run the lsof listing open files:
lsof -i :port will show the process running on this port.
lsof -U for linux open sokets.
lsof -i for network sockets
lsof -i tcp listing open tcp ports.
lsof -c c will show open processes starting with c.
lsof +d s list all directories s.
losf -N This option selects the listing of NFS files.
lsof -R This option directs lsof to list the Parent Process IDentifiā€ cation number in the PPID column.
Run the netstat command to show occupied ports:
netstat -tulpn
The above command will show the pid of process listening on port, run the command below to show the program:

ls -l /proc/pid_of_process/exe
The command fuser will show the user using this file read the man of fuser fro more details.
Top
How to sync to directories.
Use rsync to sync to directories, the command below will copy the directory a to the local directory:
raync -uvEr /a ./
The command below will sync two a local directories:
rsync -uvEr --delete /a/ a
To sync two remote dirs:
rsync -v -u -P -s -z --rsh=/usr/local/bin/ssh \
--r--times --perms --links --delete \
--exclude "*bak" --exclude "*~" \
/www/* webserver:simple_path_name
For local dirs don't uset the -z (--compress).
To dwonlaod files from the remote dir:
rasync -av --exclude-from=FILE --include-from=FILE --files-from=FILE
Top
Find open ports of your system.
To find the open ports of a network run the command:
nmap -osS 192.168.1.0/24
To save the ouput in a file run:
namp -sX localhost | egrep -v '^(Namp|Starting)' > nmap.ouput
Top
kill or freeze a user.
To freeze the user on terminal pts/2:
skill -STOP pts/2
To release:
skill -CONT pts/2\
To kill user bash:
pkill -KILL -u username bash
Top