Linux/UNIX Tutorial

  Below is a list of Linux commands, complete with descriptions and syntax. For more information on Linux (or UNIX), please return here.

Linux/UNIX Organized Topically
  • Terminology
  • Commands
  • Programs
    Basic Linux/UNIX Commands: Syntax & Definition
    [ A| B| C| D| E| F| G| H| I| J| K| L| M| N| O| P| Q| R| S| T| U| V| W| X| Y| Z]


  • UNIX Organized Topically

    Linux/UNIX Terminology
    UNIX/Linux Element Definition
    path The path through the system's directory tree, subdirectories separated by the forward slash (/).
    root Has a path of /. The root directory. Also refers to the superuser on a server, who has username "root."
    home directory The directory the user is placed into when logging in. The location of the user's files: the path.
    current directory The working directory: the location in the path/directory tree where the user is currently located.
    . Signifies the current directory. See one above.
    parent directory One directory up from the current directory.
    .. Signifies the parent directory. See one above.
    flag Modifies the accompanying command; indicated by the preceding dash (-).
    file permissions Ten slots per file or directory which indicate the permission allocated among the user, the user's group and others to read, write, and execute a file. (Ex: -rwxrwxrwx)

    Commands
    UNIX/Linux Element Definition
    cd Stands for change directory, allows the user to move between directories
    pwd Displays the working/current directory.
    mkdir Makes a new directory with the name specified.
    rmdir Deletes the empty directory specified; errors if the directory isn't empty.
    ls -al Lists all files in the current directory, along w/ other information, in one-line format.
    touch Creates an empty file with the specified filename.
    chmod Allows the user to change a file's permissions.
    chown Changes a specified file's owner to the specified user.
    cat Prints a file to the screen. See more below.
    grep Used to search for patterns within files.
    more Allows the user to read files by line or by page; useful when the file is too long to use cat.
    cp Creates a second copy of the first file.
    mv Moves the file specified to a new location, or renames the file.
    rm Removes a file. With the -r flag, can also remove a directory and its contents recursively.
    ln -s Creates a soft link (like an alias) from one file to another.
    w, who Lists the users currently logged onto the system.
    f, finger Lists the users currently logged onto the system. If a username is specified, lists user's information.
    last Lists the last (specified number) of logins, total or for a specific user. Not traceable like finger.
    ps Lists the current processes owned by the user and their process ID numbers (pids).
    kill Allows the user to terminate a process.
    passwd Initiates a program allowing the user to change their password.
    quota Prints the user's quota, containing their space limit on the server and additional information.
    find Locates files or directories with the specified pattern
    df Summarizes disk usage of mounted filesystems in blocks and percent used.
    du -k Summarizes disk usage of a specified file or directory in kilobytes
    nslookup Locates a hostname or IP number on the network.
    whoami Prints the username under which you are acting.
    man Prints the manual page (explanatory information) on almost any specified topic.
    mount Not yet added.
    watch Not yet added.

    Programs
    UNIX/Linux Element Definition
    pine TBA
    elm TBA
    top TBA
    lynx TBA
    talk TBA
    write TBA
    ftp TBA
    tin TBA
    telnet TBA


    Basic UNIX Commands: Syntax & Definition

    [ A| B| C| D| E| F| G| H| I| J| K| L| M| N| O| P| Q| R| S| T| U| V| W| X| Y| Z ]

    cat.Syntax: cat /etc/passwd. Prints the specified file (/etc/passwd) to the screen. To end scrolling, try ^C (Ctrl-C). See more for pagination. Can also be used to move and concatinate files: cat filename1 > filename2 moves filename1 to filename2. Cat filename1 >> filename2 will append the content of filename1 to the end of filename2.

    cd. Syntax: cd /home/ada/a5/rsmith. Changes to the specified (/home/ada/a5/rsmith) directory. The command cd used alone will change to your home directory, cd ~username changes to the specified user's home directory, and cd / changes to the root directory. Any directory change which starts with / (such as cd /var/spool/mail/) will start from root and work inwards, whereas a directory change (cd) not beginning with / (such as cd sem1) will move inwards from your current directory.

    chmod. Syntax: chmod u+x francais. Changes the permissions (or mode) of a specified file or directory. Here, the user (owner) is being given executable privileges on the specified filename (francais) or directory. The three permissions are read, write, or execute: who may view/read, modify, and execute the file, respectively. The three groups who for whom this is delegated are the user, who is the owner of the file, the user's group, and others outside the user's group. If you wish to change the permissions on all three simultaneously, you can also use a (all), the equivalent of using ugo. Chmod can also be used in the following manner: chmod 755 francais, where read is worth 4, write 2, and execute 1, and the first number of 755 refers to the user's permissions (4+2+1=7: read, write, and execute) and the next two refer to the user's group's and world (other) permissions (4+1=5, read and execute, for both).

    chown. Syntax: chown rsmith /home/ada/a5/rsmith. Changes the owner on the specified file or directory (/home/ada/a5/rsmith) to the specified user (rsmith). This only works if the user has executable privileges on the specified directory or file.

    cp. Syntax: cp ./ranting ./raving. Creates an additional copy of the specified file (ranting) under a new filename (raving).

    df. Syntax: df Provides a summary of disk usage for mounted, specified filesystems, listing blocks available and blocks and the percentage of the filesystem used.

    du. Syntax: du -k /home/ada/a5/rsmith. Provides a summary of the disk usage, in kilobytes, within the specified file or directory (/home/ada/a5/rsmith); if a directory, the disk usage of the subdirectories are listed recursively.

    find. Syntax: find /path -name passwd. Locates the specified string (passwd), starting from the specified path (/path). All filenames or directories containing this string will be printed to your screen.

    f, finger. Syntax: finger or finger rsmith. In the first case (f or finger): Lists all users currently logged into the UNIX system with the following information: username, user's full name, where the user is logged in from, idle time and login time. In the second case (finger or f rsmith): Lists the user's username, full name, shell, home directory, last login time, location from where they logged in, and plan. Note: if a full email address is provided instead of only a username, you may also be able to finger users at other locations. The finger command can be traceable.

    grep. Syntax: cat /etc/passwd | grep rsmith. Searches for and limits the command output to the pattern specified by the grep command; in this case, all instances of rsmith from the /etc/passwd file are printed to the screen.

    kill. Syntax: kill 8201 or kill -9 8209. Kills the process specified by the pid (or process ID number: 8201). The -9 flag forces the process to die.

    last. Syntax: last -300 or last -5 rsmith. In the first case: Prints to the screen the usernames, locations, and log-on and log-off times of the last -x logins to the system, the number x specified by the flag (-300). In the second case: Lists the location, log-on and log-off times of the specified user (rsmith)'s last -x logins, x determined by the flag (-5). The last command is not traceable.

    ln. Syntax: ln -s /usr/home/students/rsmith ./public_html. Creates a synthetic or "soft" link from the first directory or file to the second. A user changing into the public_html directory will actually be moving into the /usr/home/students/rsmith directory.

    ls -al. Syntax: ls -al. Lists information on all files (-a) in the current directory in single-line format (-l). Information includes permissions, the file's owner, last modification time, file size and filename; using ls without additional flags will exclude any hidden files (for example, those beginning with a period (.),) and the current (.) and parent (..) directories.

    man. Syntax: man vi. Prints the manual page on the specified topic (here, the text editor vi) to the screen. To scroll down a screen, use the space bar; to scroll up a screen, use letter b; to exit the man page, press q.

    mkdir. Syntax: mkdir peanuts. Makes a new directory (peanuts) in the current directory.

    mount. Syntax: mount not yet completed. Mounts a filesystem. (Not yet completed.)

    more. Syntax: more /etc/passwd. Paginates the specified file (/etc/passwd) so it can be read line by line (using RETURN or ENTER) or screen by screen (SPACE BAR). Use b to move back up one screen, and q to quit out of the file.

    mv. Syntax: mv ./paper7 ./sem1/paper7. Moves the specified file (paper7) to another location (from your current directory to within the sem1 directory).

    nslookup. Syntax: nslookup IP address Looks up the hostname (or IP address, depending on what is provide) for the IP address (in the form #.#.#.#) provided.

    passwd. Syntax: passwd. Launches a program by which the user changes their password.

    ps. Syntax: ps. Lists all current running processes, their corresponding pids (process ID numbers), and their status. S indicates a sleeping job.

    pwd. Syntax: pwd. Prints the (current) working directory. For example, if rsmith has just logged in and types pwd, he would get /home/ada/a5/rsmith.

    quota. Syntax: quota. Lists the user's quotas on the server, indicating the number of blocks used, the user's soft and hard limits on various quotas, the grace period, and the number of files they have and are permitted to have. Upon reaching the soft limit, they will get a 'quota exceeded' error messages, and after the grace period expires they will not be able to save anything else to their directory (i.e., postpone messages in pine, etc.) until they return to below their quota (soft limit); on reaching the hard limit, incoming mail will not be received.

    rm. Syntax: rm ./recipe or rm recipe. Removes the specified file (recipe), as found in your current directory. To prevent yourself from accidentally deleting all files with identical names (recipe) in and under your current directory, specify the filename in as being in your current directory with ./filename. To be prompted for confirmation of the rm command, flag it with -i. Secondly, note that the rm command can also be used to remove a directory and all the items within it recursively with the command rm -r directory_name, but use this exceedingly carefully.

    rmdir. Syntax: rmdir great_pumpkin. Removes the empty directory specified (great_pumpkin). If the directory is not empty, it will error; to remove the directory and its contents (removing files recursively), use rmdir -r great_pumpkin.

    touch. Syntax: touch testfile. Creates an empty file (testfile) without launching a text editor.

    w. Syntax: w. Lists all users currently logged into the UNIX system. Provides information such as username, login time, idle time, and the action they are currently performing. A similar command, who, lists the username, their port, and when they logged in.

    watch. Syntax: watch -3 w. Runs the specified command (w) at the particular second interval (3) as specified with the flag.

    whoami. Syntax: whoami. Tells the user who they are acting as; usually this will display your username.