Skip to main content

Linux Commands

Basic Commands

Basic Linux commands useful when working with web application deployments or servers:

  • ls: List files and directories in current folder.
    ls
    file1.txt folder1 script.sh
  • cd: Change current directory.
    cd folder1
  • pwd: Print current working directory.
    pwd
    /home/user/folder1
  • mkdir: Create a new directory.
    mkdir new_folder
  • rm: Remove files or directories.
    rm file1.txt
    rm -r folder1
  • cp: Copy files or directories.
    cp file1.txt copy.txt
    cp -r folder1 copy_folder
  • mv: Move or rename files or directories.
    mv file1.txt folder1/
    mv file1.txt file2.txt
  • cat: Output contents of a file.
    cat file1.txt
  • tail: Output last lines of a file.
    tail file1.txt
    tail -f file1.txt # Follow additions in real time
    tail -n 10 file1.txt # Show last 10 lines
  • head: Output first lines of a file.
    head file1.txt
  • grep: Search patterns in files.
    grep "word" file1.txt
  • ssh: Securely connect to a remote server.
    ssh user@server.com
  • scp: Securely copy files between hosts.
    scp file.txt user@server.com:/dest/path/
    scp user@server.com:/src/path/file.txt . # Copy from remote server to local