• 🏠 Home
  • 🧰 Online Generators
  • 📰 Blog
  • 🔎 Search
  • 📧 Contact
  • 📘 Guestbook
  • 🗞️ News
  • 💰 Support
  • ℹ️ Info: The website has been modernized to improve readability and smartphone compatibility. Feel free to report any bugs using the contact form

    Some useful commands


    Knowing which process is using a file:

    fuser file_name

    Getting the tree of a process

    ptree (or pstree) process_number

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

    Files opened by processes:

    lsof +p

    Find who uses the files in a directory:

    lsof +D /tmp

    Knowing which process is using a TCP/IP port:

    lsof -i TCP:PortNumber

    Knowing which process has an opened UDP connection to 123 tcp port of www.akadia.com server

    lsof -iUDP@www.akadia.com:123

    Split 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.dmp

    Convert spaces in file names to underscores

    for i in *\ *; do mv "$i" `echo $i | tr " " "_"`; done

    To do the opposite

    for i in *_*; do mv "$i" "`echo $i | tr "_" " "`"; done

    Test the command without changes

    for i in *\ *; do printf "$i\n" | tr " " "_"; done

    Convert all files in a directory to lowercase

    for i in *; do mv "$i" `echo $i | tr [:upper:] [:lower:]`; done

    Get more informations on a process

    ptree Process_Number

    Get all processes of a user

    ps -fu

    Copy files via scp

    scp file.txt user@destination_host:distant_path
    scp file.txt user@destination_host:distant_path/new_name

    Create a tree with rep1/rep2/rep3 in only one Unix command:

    mkdir -p rep1/rep2/rep3

     

    Go back



    (c) 2005-2025 Jérôme DESMOULINS
    Data privacy