Difference between revisions of "EGR 103/UNIX Lab"

From PrattWiki
Jump to navigation Jump to search
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
This page has some references from the first [[EGR 103]] lab.
 +
== Typos / Changes ==
 +
* Spring 2019: None Yet!
 +
 
== Items Learned ==
 
== Items Learned ==
 
=== During the UNIX Demonstration ===
 
=== During the UNIX Demonstration ===
Line 11: Line 15:
 
* <code>/</code> 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
 
* <code>/</code> 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
 
* <code>~</code> is used at the start of a path as an absolute shortcut for the user's home directory
 
* <code>~</code> is used at the start of a path as an absolute shortcut for the user's home directory
* <code>~ID</code> is used at the start of a path as an absolute shortcut for ID's home directory
+
* <code>~ID</code> 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
 
* <code>.</code> is a shortcut meaning the current directory
 
* <code>.</code> is a shortcut meaning the current directory
 
* <code>..</code> is a shortcut meaning the directory "above" the current one in the file tree
 
* <code>..</code> 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.
 
* Combinations of folder names and .. shortcuts may be strung together in any order; generally, any required .. go at the beginning.
* The folder <code>/afs</code> contains links to many different institutions throughout the world, but most of us only really have access to Duke's system.
 
[[File:ForeverAFS.jpg|center]]
 
  
 
=== While Creating/Using EGR103 Folder ===
 
=== While Creating/Using EGR103 Folder ===
Line 29: Line 31:
 
* The <code>*</code> symbol can be used to make a pattern for finding files; it will replace any number of characters, including no characters.   
 
* The <code>*</code> symbol can be used to make a pattern for finding files; it will replace any number of characters, including no characters.   
 
** <code>ls /afs/*ath*</code> will list all items in the <code>/afs</code> folder that have <code>ath</code> somewhere in the name, regardless of any characters before or after the <code>ath</code>
 
** <code>ls /afs/*ath*</code> will list all items in the <code>/afs</code> folder that have <code>ath</code> somewhere in the name, regardless of any characters before or after the <code>ath</code>
 +
<!-- CIFS!
 
** <code>cp ~mrg/public/EGR103/*.blah .</code> will copy all files ending in <code>.blah</code> from Dr. G's <code>public/EGR103</code> folder into the current working directory. Don't forget the <code>.</code> at the end!
 
** <code>cp ~mrg/public/EGR103/*.blah .</code> will copy all files ending in <code>.blah</code> from Dr. G's <code>public/EGR103</code> folder into the current working directory. Don't forget the <code>.</code> at the end!
 +
-->
 +
[[Category: EGR 103]]

Latest revision as of 00:18, 11 January 2019

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