EGR 103/UNIX Lab

From PrattWiki
Jump to navigation Jump to search

This page has some references from the first EGR 103 lab.

Typos / Changes

  • Spring 2019: None Yet!

Items Learned

During the UNIX Demonstration

  • pwd: print working directory - see where you are in the file system
  • ls: list - see what files, folders, links, and other items are in the directory specified or, if nothing is specified, the current directory
    • ls -a: list all the things, including hidden files whose names begin with a period
    • ls -l: list the additional information about items, such as who owns them and how big they are
    • ls -la OR ls -al: list all the things including the additional information
  • cd: change directory - move from wherever you are to wherever you need to be
    • cd with no path after it means change to the user's home directory
  • / is used at the very beginning of a path to indicate that the path is an absolute path from the root of the file system
  • / is used after the name of a folder in a path to indicate that what follows is the name of a folder or a file within that folder
  • ~ is used at the start of a path as an absolute shortcut for the user's home directory
  • ~ID is used at the start of a path as an absolute shortcut for ID's home directory - with CIFS, the only person's directory you can access is you so this is less useful now
  • . is a shortcut meaning the current directory
  • .. is a shortcut meaning the directory "above" the current one in the file tree
  • Combinations of folder names and .. shortcuts may be strung together in any order; generally, any required .. go at the beginning.

While Creating/Using EGR103 Folder

  • mkdir PATH: creates a new directory. If the PATH is simply a name, the folder is created within the current folder.
  • cp -i SOURCE(S) TARGET: safely copies the files indicated in SOURCE(S) to the TARGET. There are several variations of this:
    • If SOURCE is a single file and TARGET is the name of a folder, a duplicate of SOURCE, also named SOURCE, will be copied into TARGET
    • If SOURCE is a single file and TARGET is a name that does not exist yet, a duplicate of SOURCE will be made and it will be called TARGET
      • cp -i MyFile.txt ACopyOfMyFile.txt
        This will take the data from MyFile.txt and duplicate it in a file within the current directory to be named ACopyOfMyFile.txt
    • If SOURCES contain several files, the TARGET must be the name of an existing folder. Duplicates of the SOURCES will be copied into the TARGET and will maintain their original names
    If any of the files cp wants to make already exist and the -a flag is used, cp will ask before overwriting a file.
  • The * symbol can be used to make a pattern for finding files; it will replace any number of characters, including no characters.
    • ls /afs/*ath* will list all items in the /afs folder that have ath somewhere in the name, regardless of any characters before or after the ath