Presentation is loading. Please wait.

Presentation is loading. Please wait.

Viewing and Changing the Filing System

Similar presentations


Presentation on theme: "Viewing and Changing the Filing System"— Presentation transcript:

1 Viewing and Changing the Filing System

2 Ls –a, ls –l, ls –t Type ls – to list what files and directories you see in the working directory. We should have seen: action  comedy  drama  genres.txt Type ls -a – This option lists the files and directories starting with a dot (.). Files starting with a dot are hidden, and do not appear when using ls on its own. There is one additional file in this directory that is hidden: .  ..  .preferences  action  comedy  drama  genres.txt 

3 Ls –a, ls –l, ls –t When you add the –a to the ls command it is an option command. The –a in our case displays all the content in the working directory. There are other command, -l and –t -a - lists all contents, including hidden files and directories -l - lists all contents of a directory in long format -t - order files and directories by the time they were last modified

4 Ls –a, ls –l, ls –t Type ls –l – this will generate the following: total 12                                                                                         drwxr-xr-x 4 ccuser ccuser 4096 Jul  8  2015 action                                              drwxr-xr-x 4 ccuser ccuser 4096 Jul  8  2015 comedy                                           drwxr-xr-x 4 ccuser ccuser 4096 Jul  8  2015 drama                                               rw-r--r-- 1 ccuser ccuser    0 Jul  8  2015 genres.txt   

5 Ls –a, ls –l, ls –t The ls-l generates our rows, with seven columns separated by spaces. Here's what each column means: Access rights. These are actions that are permitted on a file or directory. Number of hard links. This number counts the number of child directories and files. This number includes the parent directory link (..) and current directory link (.). The username of the file's owner. Here the username is cc. The name of the group that owns the file. Here the group name is eng. The size of the file in bytes. The date & time that the file was last modified. The name of the file or directory

6 Ls –a, ls –l, ls –t Lets navigate to the comedy/ directory
Type cd comedy Type ls -alt The -t option orders files and directories by the time they were last modified. In addition to using each option separately, like ls -a or ls -l, multiple options can be used together, like ls -alt. Here, ls -alt lists all contents (-a), including hidden files and directories, in long format (-l), ordered by the date and time they were last modified (-t).

7 Copying and moving files or directories
Type: ls to see where you are in the directory Type: cd drama/biopic Type: cp frida.txt lincoln.txt (we have just copied the frida.txt into the lincolong txt file) Navigate to the drama/ directory by typing cd .. And ls to verify the directory you are in. Once you are in the drama directory type cp biopic/cleopatra.txt historical/. You have just now placed the cleopatra file into the historical directory.

8 Copying and moving files or directories
Navigate to the historical/ directory by typing cd historical. You should now see the cleopatra.txt file in the historical directory. Now we do not need to be in the working directory to place a file in another directory, we can do it another way. First, navigate up one directory by typing cd .. Then type cp biopic/ray.txt biopic/notorious.txt historical/ You will now see the ray.txt and the notorious.txt in the historical directory.

9 Copying and moving files or directories
To copy a file into a directory, use cp with the source file as the first argument and the destination directory as the second argument. Here, we copy the file biopic/cleopatra.txt and place it in the historical/ directory. To copy multiple files into a directory, use cp with a list of source files as the first arguments, and the destination directory as the last argument. Here, we copy the files biopic/ray.txt andbiopic/notorious.txt into the historical/directory.

10 Copying and moving files or directories
Now, navigate to the comedy directory Use the cd .. Command to move up the directory chain and the cd comedy command to enter the comedy directory. Create a new file named shrek.txt by typing: touch shrek.txt Next type: cp * satire/ Navigate to the satire directory by typing: cd satire, you should see the files the-office and shrek.txt in this directory Now navigate to the action directory by typing: cd ../ ../action/

11 WildCard Once in the action folder type: cp m*.txt scifi/
Now type cd scifi - you should see all the matrix.txt files in there.

12 Wildcard In addition to using filenames as arguments, we can use special characters like * to select groups of files. These special characters are called wildcards. Here, m*.txt selects all files in the working directory starting with "m" and ending with ".txt", and copies them to scifi/.

13 Moving Files Change to the action directory by typing cd ..
Type ls to see what is in this directory. You will see a superman.txt and a superhero directory. We want to move the superman.txt to superhero directory by typing: mv superman.txt superhero/ Navigate to the superhero/ directory by typing: cd superhero Type ls to see the superman.txt that is now in the superhero directory.

14 Moving Files Type cd .. To move up one directory to action/
Move wonderwoman.txt and batma.txt to superhero/ by typing: mv wonderwoman.txt batman.txt superhero/ Navigate to the superhero directory (cd superhero) and type ls to see wonderwoman.txt and batman.txt in the directory.

15 A tricky Move – the rename
Under the superhero directory you will see batman.txt, superman.txt and wonderwoman.txt. Type mv batman.txt spiderman.txt You should see that batman.txt has been renamed as spiderman.txt

16 move 1. my superman.txt superhero/ To move a file into a directory, use mv with the source file as the first argument and the destination directory as the second argument. Here we move superman.txt into superhero/. 2. mv wonderwoman.txt batman.txt superhero/  To move multiple files into a directory, use mvwith a list of source files as the first arguments, and the destination directory as the last argument. Here, we move wonderwoman.txt andbatman.txt into superhero/. 3. mv batman.txt spiderman.txt To rename a file, use mv with the old file as the first argument and the new file as the second argument. By moving batman.txt into spiderman.txt, we rename the file as spiderman.txt.

17 remove Return to the movies directory and move to the comedy/slapstick by typing in cd .. To get back to the movies directory and then type cd comedy/slapstick Type ls to see what is in the directory. Type rm waterboy.txt You will now see waterboy.txt is gone

18 Remove Navigate up one directory by typing cd .. to get to the comedy directory. Type ls to see what is in the directory Type rm –r slapstick Type ls and you should see that slapstick directory is now gone.

19 Remove The rm command deletes files and directories. Here we remove the file waterboy.txt from the filesystem. The -r is an option that modifies the behavior of the rm command. The -r stands for "recursive," and it's used to delete a directory and all of its child directories. Be careful when you use rm! It deletes files and directories permanently. There isn't an undelete command, so once you delete a file or directory with rm, it's gone !!

20 What have we learned Options modify the behavior of commands:
ls -a lists all contents of a directory, including hidden files and directories ls -l lists all contents in long format ls -t orders files and directories by the time they were last modified Multiple options can be used together, like ls -alt

21 What we have learned so far
From the command line, you can also copy, move, and remove files and directories: cp copies files mv moves and renames files rm removes files (rm –r can also remove files). rm -r removes directories (rmdir can also remove directories). Wildcards are useful for selecting groups of files and directories

22 Assignment Create the second filing system you created in the previous lesson. Create a new directory called “copied” in the blog directory (the one with your name) and copy files from the original directory to the newly created “copied” directory. Move the files and re-order them in the new copied directory, rename the new files and directories, make this filing system something that makes more sense to you. Ultimately, you just need to practice using the rm, mv, cp commands. Also, use the ls –l, ls –a, ls –t, to view and understand what you are looking at after using them.


Download ppt "Viewing and Changing the Filing System"

Similar presentations


Ads by Google