About Linux

The majority of internet servers (90%) are powered by some form of Linux. The advantages of using Linux are that it is free, highly customizable, fast, and secure. Windows, on the other hand, is costly and is one of the most vulnerable operating systems ever created. The Android smartphone operating system is also built on Linux.

The Command Line Interface

A command line interface (CLI) interprets commands that a user inputs and then outputs the result of their execution. A shell is a program provided by the OS which is a type of CLI and allows the user to run other programs.

From Wikipedia:

A shell is a user interface for access to an operating system’s services.

The most basic shell is sh.

bash is the most common shell for Linux. It has many more features and is easier to use than sh, and is nearly universal. There are other less common shells too, such as fish (Friendly Interactive SHell) and zsh.

bash features

* represents a wild card, or fill-in-the-blank. For example, ls *.html would list all files in the current directory with the given extension (.html).

Also know that . represents the current working directory, while .. represents the parent directory.

A more detailed guide of basic commands can be found here: https://gitlab.com/wsec/club/wikis/Basic-UNIX-and-bash-commands.

Basic commands

  • pwd prints the absolute path of the current working directory

  • echo Hello world!

  • ls [DIR] displays the contents of the directory DIR. Append -a to include hidden files.

  • cd [DIR] changes the current working directory to DIR. You must surround a directory with spaces in quotes or add a backslash before any spaces: cd "New Folder" or cd New\ Folder. User cd .. to go up one level.

  • mkdir [DIR] creates a new directory.

  • rmdir [DIR] deletes an empty directory.

  • rm [FILE] deletes a file.

  • touch [FILE] creates a blank file called FILE.

  • cat concatenates the input stream and prints to the output stream. (?)

    • cat [FILE] prints the content of FILE

    • cat > [FILE] will write the standard input stream out to FILE. End this command by pressing CTRL-D.

    • cat >> [FILE] will append the standard input stream to the end of FILE, not overwriting its original contents.

  • cp [FILE] [DESTINATION] will copy FILE to the DESTINATION location.

  • mv [FILE] [DESTINATION] will move FILE to the DESTINATION, removing it from its original location. This command can also be used to rename files: mv file.txt newName.txt.

  • man COMMAND shows the manual page for COMMAND. You can also add -help or --help to the end of any command.

  • sudo COMMAND runs COMMAND with superuser (root) privileges.

  • apt is a front-end to the Debian package manager.

    • apt update updates the package list.

    • apt upgrade updates the packages.

    • apt install PACKAGE0, PACKAGE1... installs the packages listed. Must be ran as root.

    • apt remove [--purge] PACKAGE0, PACKAGE1... uninstalls the packages. With the optional parameter --purge, all configuration and data files are deleted as well.

    • apt autoremove removes all orphaned packages (unused dependencies).

    • apt search KEYWORD searches the repository for KEYWORD.

Note: Every apt subcommand listed above excluding search must be run as root. sudo apt install...

CTRL-C ususally cancels the foreground command by sending SIGINT or a KeyboardInterrupt.