Skip to content

Linux & unix bash Commands

ibrahim edited this page Jul 23, 2024 · 1 revision

Common Unix Shell / Linux Commands

Unix shell or Linux commands are essential tools for interacting with your system's operating system. Here are some basic commands to get you started:

  • ls : Lists the files and directories in the current directory.

    ls
  • pwd : Displays the current working directory.

    pwd
  • cd : Changes the current directory.

    cd /path/to/directory
  • cat : Concatenates and displays the content of files.

    cat filename
  • mv : Moves or renames files and directories.

    mv oldfilename newfilename
  • cp : Copies files and directories.

    cp sourcefile destinationfile
  • mkdir : Creates a new directory.

    mkdir newdirectory
  • rm : Removes files or directories.

    rm filename

    To remove a directory and its contents:

    rm -r directoryname
  • wc : Prints newline, word, and byte counts for each file.

    wc filename
  • sort -n : Sorts lines of text files numerically.

    sort -n filename
  • head -n : Outputs the first n lines of a file.

    head -n 10 filename

Operators

Operators are used to manipulate data and files in Unix/Linux.

  • > : Redirects the output of a command to a file, overwriting the existing content.

    command > outputfile
  • | : The pipe operator, used to pass the output of one command as input to another command.

    command1 | command2
Clone this wiki locally