Sections
Some useful commands
Knowing which process is using a file:
fuser file_nameGetting the tree of a process
ptree (or pstree) process_numberKnowing who is using what
lsof Examples:From an executable (or a script):
lsof -t /path/executable_file lsof -c file (ex: lsof -c bash)List of files opened by a Unix account:
lsof -u oracleFiles opened by processes:
lsof +pFind who uses the files in a directory:
lsof +D /tmpKnowing which process is using a TCP/IP port:
lsof -i TCP:PortNumberKnowing which process has an opened UDP connection to 123 tcp port of www.akadia.com server
lsof -iUDP@www.akadia.com:123Split a file:
split -b 100000000 ../exp_tytan_chagall.dmp dump. Generates all files of 100 MB as necessary for the split. The files will be named dump.aa, dump.ab ...Unsplit a file:
cat dump.* > exp_tytan_chagall.dmpConvert spaces in file names to underscores
for i in *\ *; do mv "$i" `echo $i | tr " " "_"`; doneTo do the opposite
for i in *_*; do mv "$i" "`echo $i | tr "_" " "`"; doneTest the command without changes
for i in *\ *; do printf "$i\n" | tr " " "_"; doneConvert all files in a directory to lowercase
for i in *; do mv "$i" `echo $i | tr [:upper:] [:lower:]`; doneGet more informations on a process
ptree Process_NumberGet all processes of a user
ps -fuCopy files via scp
scp file.txt user@destination_host:distant_pathscp file.txt user@destination_host:distant_path/new_name