Changes between Version 10 and Version 11 of cypress/BasicLinuxComands


Ignore:
Timestamp:
Aug 19, 2015 7:23:42 AM (6 years ago)
Author:
cmaggio
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • cypress/BasicLinuxComands

    v10 v11  
    6363[tulaneID@cypress1 ~]$ ls
    6464a.out  code.c  Makefile
     65}}}
     66
     67If you would like to see if a directory contains a specific file, you can pass the directory path and file name to '''ls''' as an argument
     68{{{
     69[tulaneID@cypress1 ~]$ ls a.out
     70a.out
    6571}}}
    6672
     
    297303}}}
    298304
     305=== find ===
     306Searches for files in a directory hierarchy. The '''find''' takes a directory as an argument and will search in that directory and all of it's subdirectories for files that match the search criteria. If no directory is specified, the current directory is used.
     307
     308You can search for a file by name using the '''-name''' flag as your search criteria
     309{{{
     310[tulaneID@cypress1 ~]$ find /home/tulaneID/ -name file1.txt
     311/home/tulaneID/dir1/file1.txt
     312[tulaneID@cypress1 ~]$
     313}}}
     314
     315One can also search for all files that have a string of text in any portion of their name by using the star wildcard, e.g. we can find all the .txt files in our HOME directory and it's subdirectories. Note that quotes are required around our criteria as we are now using a ''regular expression''
     316
     317{{{
     318[tulaneID@cypress1 ~]$ find /home/tulaneID/ -name "*.txt"
     319/home/tulaneID/textfile02.txt
     320/home/tulaneID/dir1/file1.txt
     321/home/tulaneID/examples/alphabet.txt
     322/home/tulaneID/examples/numbers.txt
     323/home/tulaneID/textfile01.txt
     324[tulaneID@cypress1 ~]$
     325}}}
     326
     327These are just a couple examples of the many ways '''find''' can be used. A nice short tutorial on '''find''' with a lot of examples can be found at http://alvinalexander.com/unix/edu/examples/find.shtml
     328
    299329== Advanced Linux Commands ==
     330
     331=== chmod  ===
     332The '''chmod''' commands allow a user to modify the permissions of files and directories that they own. To see the permissions of a file/directory we can use the '''ls -l''' command
     333
     334{{{
     335[tulaneID@cypress1 ~]$ ls -l
     336total 4
     337-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 a.out
     338-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 helloworld.c
     339-rw-r--r-- 1 tulaneID workshop    0 Aug 19 07:15 myscript.sh
     340drwxr-xr-x 2 tulaneID workshop 4096 Aug 18 21:37 NextDirectoryDown
     341-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 textfile01.txt
     342-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 textfile02.txt
     343[tulaneID@cypress1 ~]$
     344}}}
     345
     346The ten left most characters describe your permissions. The first character describes the file type (- for a file, d for a directory). The next three describe the permissions for the user who owns the file, the middle three describe the permissions for the group that owns the file, and the last three describe the permissions for "others". The "r" denotes permission to read, the "w" means permission to write, and the "x" indicates permission to execute the file/directory.
     347
     348The change mode or '''chmod''' command allows us to alter those permissions. In the past one had to remember (or google) numeric codes that corresponded to permission states, but modern syntax allows for the addition and subtraction of permissions with greater ease. Now one needs only indicate whose permissions to change and what changes to make. For example, let's add executable permissions for the user to the file myscript.sh
     349
     350{{{
     351[tulaneID@cypress1 ~]$ chmod u+x myscript.sh
     352[tulaneID@cypress1 ~]$ ls -l
     353total 4
     354-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 a.out
     355-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 helloworld.c
     356-rwxr--r-- 1 tulaneID workshop    0 Aug 19 07:15 myscript.sh
     357drwxr-xr-x 2 tulaneID workshop 4096 Aug 18 21:37 NextDirectoryDown
     358-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 textfile01.txt
     359-rw-r--r-- 1 tulaneID workshop    0 Aug 18 21:50 textfile02.txt
     360}}}
     361
     362The user (and only the user) can now run the script myscript.sh as an executable. For a more complete introduction see http://alvinalexander.com/linux-unix/linux-chmod-command-permissions-file-directories
    300363
    301364=== sed ===