1 / 23

Linux file system

Linux file system. "On a UNIX system, everything is a file; if something is not a file, it is a process.". Sorts of files (on a Linux system). Directories : files that are lists of other files. Special files : the mechanism used for input and output. Most special files are in /dev. Links

sarawagner
Télécharger la présentation

Linux file system

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories: files that are lists of other files. Special files: the mechanism used for input and output. Most special files are in /dev. Links Sockets and Named pipes: files are used to pass information between applications amongst other applications

  2. The -l option to ls displays the file type File types in a long list SymbolMeaning - Regular file d Directory l Link c Special file s Socket p Named pipe

  3. File system layout / dev mnt boot home proc root sbin bin etc lib opt tmp usr var

  4. each subdirectory of root have special roles(By tradition): /bin: executable commands /sbin: sys adm commands /etc: system configuration files /lib shared libraries /dev peripheral devices /tmp temporary files /mnt to mount external devices /var Storage for all variable files and temporary files created by users, such as log files /proc system information /usr/bin further exe files /usr/sbin further system-important exe files /usr/lib further libraries User-installed programs typically go under the /usr/local hierarchy

  5. The df command [alaei@node65 ~]$ df -h Using the df command with a dot (.) as an option shows the partition the current directory belongs to, [alaei@node65 ~]$ df -h .

  6. The file system in reality In a file system, a file is represented by an inode, a kind of serial number containing information about the actual data that makes up the file: to whom this file belongs, and where is it located on the hard disk. use ls -i to disply indoe numbers

  7. Orientation in the file system The PATH environment variable lists those directories in the system where executable files can be found [alaei@node65 ~]$ echo $PATH Linux searches for required program in paths and as soon as a match is found, the search is stopped The which command The export command The env command

  8. Absolute and relative paths A path, which is the way you need to follow in the tree structure to reach a given file, can be described as starting from the trunk of the tree (the / or root directory). In that case, the path starts with a slash and is called an absolute path In the other case, the path doesn't start with a slash and confusion is possible between ~/bin/wc (in the user's home directory) and bin/wc in /usr. Paths that don't start with a slash are always relative. In relative paths we also use the . and .. indications for the current and the parent directory ~ means usr home directory

  9. Manipulating files more about ls ls -l ls -ltr In most UNIX commands, options can be combined Color ls default color scheme Color Filetype blue directories red compressed archives white text files pink images cyan links yellow devices green executables flashing red broken links

  10. Crating and deleting files and directories nautilus: The default file manager in Gnome, the GNU desktop. konqueror: The file manager typically used on a KDE desktop. mc: Midnight Commander, the Unix file manager

  11. creating directories mkdir mkdir -p : creating directories and subdirectories in one step [alaei@node65 ~]$ mkdir -p project/iut/1 [alaei@node65 ~]$ mkdir 1 2 5

  12. Copying files with cp -i, interactively prompt before overwriting files -R, -r, --recursive copy directories recursively Moving Files with mv mv can rename files or directories, or move them to different directories -f, force overwrite, even if target already exists -i, ask user interactively before overwriting files

  13. Deleting Files with rm -f, delete write-protected files without prompting -i, interactive ask the user before deleting files -r, recursively delete files and directories There is no recycle bin in shell so s file is really gone when you use rm

  14. Finding Files with locate The locate command is a simple and fast way to find files The locate command searches a database of filenames The database needs to be updated regularly Usually this is done automatically with cron But locate will not find files created since the last update Options: -i option makes the search case-insensitive -r treats the pattern as a regular expression, rather than a simple string

  15. Finding Files More Flexibly: find find <path> name <searchstring> [alaei@node65 ~]$ find . -name test [alaei@node65 ~]$ find . size +5000k

  16. The grep command The diff command The tkdiff command

  17. File Security Owner Group Others d r w x r w x r w x Execute File type Write .= file d= directory l= link Read

  18. Each type of permission is assigned a access mode code: read = 4 or r write = 2 or w execute = 1 or x User group codes user = u group= g others= o

  19. The id command Print information for USERNAME, or the current user. The chmod command Operation + add - remove = set exactly

  20. Before: -rwxr-xr-x  archive.sh Command: chmod o=r archive.sh After: -rwxr-xr--  archive.sh Before: -rw-r-----   topsecret.inf Command: chmod g= topsecret.inf After: -rw-------    topsecret.inf Before: -rw-r--r--    publicity.html Command: chmod og=rw publicity.html After: -rw-rw-rw-   publicity.html

  21. $ ls -l test_file -rw-r--r-- 1 eric users $ chmod o-r test_file $ ls -l test_file -rw-r----- 1 eric users $ chmod g+wx test_file $ ls -l test_file -rw-rwx--- 1 eric users $ chmod u=rw,g=r,o=r test_file -rw-r--r-- 1 eric users For changing file permissions in directory trees use -R. $ chmod -R g-w test_dir

  22. $ chmod 754 test_file -rwxr-xr-x 1 eric users Owner = 4 + 2 + 1 = 7 Group = 4 + 1 = 5 World = 4 = 4 The permission numbers are determined by adding the values of the allowed permissions: 7 = read + write + execute 6 = read + write (but not execute) 5 = read + execute (but not write) 3 = write + execute (but not read) 4 = read (but not write and execute) 2 = write (but not read or execute) 1 = execute (but not read or write)

  23. The newgrp , chown and chgrp commands

More Related