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
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
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
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