Kernel Shell Terminal Commands Notes

Root File Structure

  • bin – binary executables
  • home – users home directory
  • proc – processes
  • dev – devices
  • lib – 32 bit libraries (shared files aka dll)
  • lib64 – 64 bit libraries (shared files aka dll)
  • opt – optional software
  • etc – configuration files

Hardware Abstraction Layer Protects the Kernel

Terminal aka Shell – Command Line Interface

When you launch a program, a virtual environment is spawned and rules are applied to protect the Kernel

Terminal Commands

  • sh : the command name of the Bourne shell, the standard command language interpreter of Unix and many Unix-like operating systems, including Linux.
  • bash : a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell.
  • exit – close current instance.
  • ls : lists all files in the directory that match the name. If name is left blank, it will list all of the files in the directory.
    • $ ls [options] [file|dir]
    • -l : Displays the long format listing.
  • cd $ cd [directory]
    • Change to home directory (determined by $HOME environment variable):
      • $ cd
    • Also change to home directory:
      • $ cd ~
    • Change to root directory:
      • $ cd /
    • Change to parent directory:
      • $ cd ..
    • Change to subdirectory Documents:
      • $ cd Documents
    • Change to subdirectory Documents/Books:
      • $ cd Documents/Books
    • Change to directory with absolute path /home/user/Desktop:
      • $ cd /home/user/Desktop
    • Change to directory name with white space – My Images:
      • $ cd My\ Images
      • $ cd “My Images”
      • $ cd ‘My Images’
  • cat : command is used to display the content of text files and to combine several files to one file. The cat command does not accept directories.
    • $ cat [options] file1 [file2…]
    • cat -b : add line numbers to non blank lines
    • cat -n : add line numbers to all lines
    • cat -s : squeeze blank lines to one line
    • cat -E : show $ at the end of line
    • cat -T : show ^I instead of tabs
  • cp : copy files and directories – $ cp [options] source dest

    • -a : archive files
    • -f : force copy by removing the destination file if needed
    • -i : interactive – ask before overwrite
    • -l : link files instead of copy
    • -L : follow symbolic links
    • -n : no file overwrite
    • -R : recursive copy (including hidden files)
    • -u : update – copy when source is newer than dest
    • -v : verbose – print informative messages
  • mv : move files and directories – $ mv [options] source dest
    • -f : force move by overwriting destination file without prompt
    • -i : interactive prompt before overwrite
    • -u : update – move when source is newer than destination
    • -v : verbose – print source and destination files
    • man mv : help manual
  • rm : remove file
    • $ rm [OPTION]… [FILE]…
    • -r, -R, –recursive : Remove directories and their contents recursively.
    • -f, –force : Ignore nonexistant files, and never prompt before removing.

Permissions

  • r : Read
  • w : Write
  • x :
    • File: Execute
    • Directory: List Directory
  • File permissions: -rwxrwxrwx
    • – file
    • 1st 3 rwx : Owner
    • 2nd 3 rwx : Group
    • 3rd 3 rwx : Others
  • Directory Permissions: lrwxrwxrwx or drwxrwxrwx
    • l – link
    • d – directory
    • 1st 3 rwx – Owner
    • 2nd 3 rwx – Group
    • 3rd 3 rwx – Others
  • Default File permissions: -rw-rw-r–

File and Folder Management

  • directory – folders
  • permissions are assigned to files and folders to determine who has access to it
  • A directory has a different permissions structure than a file
  • A directory needs execute permissions to be able to see the contents of the directory
  • . (dot) : current relative path
  • .. (dot dot) : current relative path one level up