User Tools

Site Tools


wiki:options2018

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:options2018 [2018/07/06 17:18]
david created from old site
wiki:options2018 [2018/08/23 04:59] (current)
erin
Line 1: Line 1:
-====== Making & Removing ====== 
  
-===== Making Directories =====+--> Quiz\\ 
 +--> Assignment\\ 
 +--> Canvas\\ 
 +--> Summit
  
-We can make a new directory using the command ''​mkdir''​ (MaKe DIRectory): 
  
-**mkdir** <​newdirectoryname>​ ... 
  
-;-) **Quick Tip**: The ... means that you can add either one or more newdirectorynames.+====== OPTIONS ======
  
-:!: **Exercise**: Let's make a new directory called "​mynewdir":​+Up to this point, we have used commands without arguments and commands with arguments. In addition to this, we can execute commands with **options**. Options are bells and whistles we can append to our commands to customize the way the shell interprets the commands.
  
-<code bash> +Here are a few options for the command ''​ls''​ courtesy of [[ http://​linuxcommand.org/​tlcl.php | The Linux Command Line ]] :
-$mkdir mynewdir +
-$ls +
-</code>+
  
 +{{ :​wiki:​screen_shot_2016-08-17_at_4.37.38_pm.png?​500 |}}
  
-===== Removing Directories =====+Options are added after the command itself but before any arguments.
  
-We can remove empty directories using ''​rmdir''​ (ReMove DIRectory):+**command** [options] [arguments]\\  
 +**command** [options] <​arguments>​
  
-**rmdir** ​<directoryname> ...+[] -- optional. The command will work with or without these\\  
 +<> ​-- requiredThe command requires these arguments
  
-:!: **Exercise**:​ Let's remove ​the "​mynewdir"​ directory:+Short options take one dash. Long options take two dashes 
 + 
 +Further, short options can often be lumped together. 
 + 
 +For example, ​the following commands //should// do the same thing...
  
 <code bash> <code bash>
-$ls +$ ls -a 
-$rmdir mynewdir +$ ls --all
-$ls+
 </​code>​ </​code>​
  
 +And these commands //should// do the same thing...
  
----- +<code bash> 
- +$ ls --all --human-readable ​-l 
- +ls ---l 
-:!: **More Exercises**:​  +$ ls -ahl 
-  ​Through the terminal, navigate to the place in your computer where you want to store files for this class. If you haven'​t already made a directory specifically for this class, use ''​mkdir''​ to make that directory. +</​code>​
-  ​Navigate inside your new course directory. +
-  - Make some subdirectories for the course like "​Assignments",​ "​Notes",​ "​Exercises"​. +
-  - Check out your subdirectories using ''​ls''​ +
-  ​Hmm, maybe those subdirectories don't sort the way you want them to. Delete the directories "​Assignments",​ "​Notes',​ and "​Exercises"​. +
-  ​You can add multiple directories by listing new directory names after ''​mkdir''​ separated by spaces: +
-  ​''​mkdir dir1 dir2 dir3''​ +
-  Using one ''​mkdir''​ command, make the directories "​01_Notes",​ "​02_Exercises",​ "​03_Assignments"​. +
-  - Now ''​ls''​ to see the subdirectories.+
  
  
Line 50: Line 46:
  
  
-===== Making Files =====+:!::!::!: **Exercise**:​ Let's obtain a dataset to allow us to explore ''​ls'':​
  
-Files are documents that live within directories. All files in the Linux environment should follow some naming standards..+  * Download ​the following file: {{:​wiki:​160825_options_ex.tgz|}} ​ 
-  * NO spaces +  * Using Finder/​Explorernavigate to the location where you downloaded the file. 
-  * NO weird characters (A-Z0-9, _, - are OK) +  * Double click on the .tgz file to decompress it.
-  * Should contain a file extension (.txt, .docx, .png, etc)+
  
- +;-) **Quick Tip**: If double clicking on the "​tarball"​ doesn't open it, try using tar on the command line:
-There are many ways to make a new file. We'll cover just a few: +
- +
-==== Making files with touch ==== +
- +
-We can make a new file with touch: +
- +
-**touch** <​filename.txt>​ +
- +
-:!: **Exercise**:​ Let's navigate into your directory **01_Notes** and make the file ''​quick_tips.txt''​.+
  
 <code bash> <code bash>
-$touch quick_tips.txt +tar -zxvf 160825_options_ex.tgz
-$ls +
-$ls -alh +
-$less quick_tips.txt #peek into the file quick_tips.txt+
 </​code>​ </​code>​
  
  
-Well, that's a pretty boring file. Let's add some content to it using the linux text editor called ​**nano**. This command will be different than previous commands we've executed. Instead of spitting something out to the screen below the prompt, **nano** will take us to a little text editor app within ​the terminal ​where we can type in some textTo exit out of nanotype CTRL+X. To savetype ''​y''​.+  ​If you need to, move the resulting expanded directory and its contents ​to a location you can easily manipulate in the terminal. 
 +  * Open your terminal and navigate (''​cd''​''​pwd''​, ''​ls''​) to the directory ''​160825_options_ex''​.
  
-:!: **Exercise**: ​Let's add content to ''​quick_tips.txt'' using nano:+:!: **Exercise**: ​Try executing ​''​ls'' ​commands:
  
 +  * Try ''​ls -a -l -h''​
 +  * Try ''​ls -alh''​
 +  * Which combination of ''​ls''​ options would you execute to list the contents in the following order and format?:
 <code bash> <code bash>
-$nano quick_tips.txt+total 184 
 +-rw-r--r--@ 1 erinonish ​ staff    99B Aug 24 19:38 ce11_chrom_sizes.txt 
 +-rw-r--r--@ 1 erinonish ​ staff   800B Aug 24 19:51 README_download.txt 
 +-rw-r--r--@ 1 erinonish ​ staff   1.4K Aug 24 19:39 mm10_chrom_sizes.txt 
 +-rw-r--r--@ 1 erinonish ​ staff    11K Aug 24 19:41 hg38_chrom_sizes.txt 
 +-rw-r--r--@ 1 erinonish ​ staff    23K Aug 24 19:42 danRer10_chrom_sizes.txt 
 +-rw-r--r--@ 1 erinonish ​ staff    44K Aug 24 19:37 dm6_chrom_sizes.txt
 </​code>​ </​code>​
- 
-  * Type in some content. 
-  * Remember, to exit out of nano, ''​CTRL+X''​. ​ 
-  * To see what happened, let's look in the file using ''​less''​. 
- 
-<code bash> 
-$less quick_tips.txt 
-</​code>​ 
- 
-==== Making files with nano ==== 
- 
-We can also make new files by skipping touch and just starting up nano directly. ​ 
- 
-:!: **Exercise**:​ Let's make the new file ''​common_pitfalls.txt''​. 
- 
-<code bash> 
-$nano common_pitfalls.txt 
-</​code>​ 
- 
-We will learn other ways to create new files in future lessons, too.  
  
  
 ---- ----
  
 +=== Manuals ===
  
-===== Removing Files =====+Reading a book or a webpage about options can sometimes lead you astray. This is because different commands work differently across different linux "​distros"​. Sometimes the manual for a given command is more useful.
  
-We can remove files using ''​rm''​ (ReMove). +**//Manual Usage//** \\ 
- +**man** <​command_name>​
-**rm** [-i] <​filename.txt>​ +
- +
-''​-i''​ is an **option** for to run ''​rm''​ interactively. It requests a confirmation to remove. Please get in the habit of using this option. +
- +
-m( **Common pitfall**: **THERE IS NO UNDO IN LINUX**. Yep, that's right. If you remove a file, it's gone. There'​s no trash can or recycle bin you can pull that file out of. It is gone-gone.  +
- +
-;-) **Quick tip**: Always make sure you have a good backup system in place. A good back up system is automatic. +
- +
-Let's say we don't want the file ''​common_pitfalls.txt''​ anymore.+
  
 <code bash> <code bash>
-$ls +man ls
-$rm -i common_pitfalls.txt +
-$ls+
 </​code>​ </​code>​
  
----- +:!: Use the **SPACE** bar to navigate ​through the manual ​pages.
-:!: **More Exercises**:​  +
-  - Navigate to the course directory. If you execute the ''​ls''​ command, you should see the directories "​01_Notes",​ "​02_Exercises",​ "​03_Assignments"​ +
-  - Navigate into 02_Exercises.  +
-  - Create a new file with today'​s date somewhere in the filename and a '​.txt'​ file extension. +
-  - Copy and paste the instructions for this exercise into the new text file.  +
-  - Use ''​less''​ to peek into your new text file. +
-  - Use ''​rm -i''​ to delete your newly made text file. +
- +
-;-) **Quick tip**: When using ''​less'' ​to browse a short file, the prompt will return immediately. However, if your file is long, use ''​spacebar''​ to scroll ​through the pages and ''​q''​ to escape back to the prompt. +
- +
----- +
- +
-===== Removing directories and their contents with rm ===== +
- +
- +
-We can also remove directories AND all their contents using ''​rm'':​ +
- +
-**rm** [-ir] <​directoryname>​\\  +
-  * -i                interactive. request confirmation to remove. +
-  * -r                recursive. remove entire directory and contents. +
-  * <​directoryname> ​  the name of the directory you want to remove +
- +
-Always specify ''​-i''​ because there is the potential for deleting more than you bargained for. +
- +
-m( **Common pitfall**: Until you are at Linux ninja status, please use ''​-i''​ with all your ''​rm''​ commands. Please use caution when using ''​rm''​. Also, please have a good backup strategy in place as well. +
- +
-{{:​wiki:​slide2_arrow.png?​40|}} [[ wiki:​2018cpmv | Continue to Copy & Move ]] +
- +
- +
- +
- +
- +
- +
  
 +:!: Use **Q** to quit out of the manual pages.
  
 +:!: I hate to tell you this, but sometimes the man pages are also inaccurate. ​
  
 +[[wiki:​make2018|{{:​wiki:​slide2_arrow.png?​40|}}]] [[wiki:​make2018|Making & Removing]]
wiki/options2018.1530919112.txt.gz · Last modified: 2018/07/06 17:18 by david