C2110 UNIX and programming Lesson 4 / Module 2 -1C2110 UNIX and programming Petr Kulhanek kulhanek@chemi.muni.cz National Center for Biomolecular Research, Faculty of Science Masaryk University, Kamenice 5, CZ-62500 Brno PS / 2020 Distance form of teaching: Rev1 Lesson 4 / Module 2 C2110 UNIX and programming Lesson 4 / Module 2 -2File System C2110 UNIX and programming Lesson 4 / Module 2 -3- Quotas Quotas are set for your home directories on disk partition wolf.ncbr.muni.cz:/home/. The current status and quota settings can be seen by the command quota: [kulhanek@wolf ~]$ quota -vs Disk quotas for user kulhanek (uid 18773): Filesystem blocks quota limit grace files quota limit wolf.ncbr.muni.cz:/home/ 1550M 1954M 2051M 20453 0 0 Current use Quota that can be temporarily exceeded. Hard limit that cannot be exceeded. Exceeded quota can lead to unsuccessful login using a graphical interface. In this case, log into a text terminal (e.g., Ctrl + Alt + F1) and move the files to another partition (e.g., temporarily to the /scratch/username or delete unnecessary files). C2110 UNIX and programming Lesson 4 / Module 2 -4Disk Device Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/server1-root ext4 15G 8.4G 5.5G 61% / none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup udev devtmpfs 3.9G 4.0K 3.9G 1% /dev tmpfs tmpfs 793M 888K 792M 1% /run none tmpfs 5.0M 0 5.0M 0% /run/lock none tmpfs 3.9G 952K 3.9G 1% /run/shm none tmpfs 100M 36K 100M 1% /run/user /dev/mapper/server1-vbox ext4 64G 52G 9.5G 85% /win /dev/mapper/server1-scratch ext4 598G 2.8G 565G 1% /scratch wolf.wolf.inet:/software/ncbr nfs4 197G 156G 33G 83% /software/ncbr wolf.wolf.inet:/home/ nfs4 493G 371G 98G 80% /home device file system type mount point An overview of file system usage, disk devices, and their mount points is provided by the command df. Ext3, ext4 third / fourth extended filesystem (native file system of linux) nfs3, nfs4 network filesystem Vfat Virtual File Allocation Table (file system used by MS Windows) ntfs New technology File System (developed by Microsoft for its operating systems) File system types: !!! not case-sensitive !!! - Be careful when copying files with different cases C2110 UNIX and programming Lesson 4 / Module 2 -5USB Drives [kulhanek@wolf01 ~]$ df -Th Filesystem Type Size Used Avail Use% Mounted on ................................................................................ wolf.ncbr.muni.cz:/home nfs4 280G 164G 102G 62% /home /dev/sdg1 vfat 962M 841M 122M 88% /media/kulhanek/B19A-1CA2 In the graphic environment, USB drives connect automatically into the bundle /media/username. [kulhanek@wolf01 ~]$ umount /media/kulhanek/B19A-1CA2 The disk can be disconnect in a graphical environment or by a command umount. The command argument is the device mount point. The disk can be disconnected only if it is not in use (no file must be open, no process must have a (sub)directory from the mount point, including the mount point, set as the working directory). An overview of the processes using the given directory (mount point) can be obtained by the command lsof (or fuser). [kulhanek@wolf01 ~]$ lsof /media/kulhanek/B19A-1CA2/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME bash 31521 kulhanek cwd DIR 8,97 4096 518 /media/kulhanek/B19A-1CA2/GoslarFinal bash 31893 kulhanek cwd DIR 8,97 4096 518 /media/ kulhanek/ B19A-1CA2/GoslarFinal vi 32011 kulhanek cwd DIR 8,97 4096 518 /media/ kulhanek/ B19A-1CA2/GoslarFinal C2110 UNIX and programming Lesson 4 / Module 2 -6- Links Links: ➢ Hard links ➢ Symbolic links (soft links) Symbolic links (soft links) lrwxrwxrwx 1 root root 21 Oct 5 21:06 krb5.conf -> /etc/krb5.conf.EINFRA -rw-r - r-- 1 root root 4848 Oct 5 20:37 krb5.conf.EINFRA symbolic link real file link target Properties of symbolic links: • contain information about the path to the target object (file, directory,…) • from the point of view of the system, they behave as the target object • access rights are derived from the target object • the target object may not exist • they are created with the command ln with the -s option, example: ln –s /etc/krb5.conf.EINFRA krb5.conf C2110 UNIX and programming Lesson 4 / Module 2 -7Overview of Commands File system: cd changes the current working directory pwd lists the path to the current working directory ls lists the contents of a directory Mkdir creates a directory rmdir deletes a directory (must be empty) Cp copies a file or directory mv moves a file or directory rm deletes a file or directory find searches for files or directories Id lists the user's groups getent lists information about users, user groups, and other information chmod changes access rights to a file or directory chown changes the owner of the file or directory chgrp changes the access group of a file or directory umask default access rights for newly created files or directories basic operations access rights C2110 UNIX and programming Lesson 4 / Module 2 -8Overview of Commands File system (continued): quota prints information about set quotas for mount points du lists the size of directories or files stat lists detailed information about a file or directory df lists information about mounted partitions lsof lists processes that have files / directories open on a mount point (directory) ln creates a link to a file or directory unlink unlinks a file or directory advanced functions C2110 UNIX and programming Lesson 4 / Module 2 -9Exercise 1 1. Use the command quota to view the current occupancy of your home directory on a WOLF cluster. 2. Download this presentation to your home directory. 3. What is the size of the presentation file? 4. Create a symbolic link to the presentation named lesson4.pdf. 5. What is the size of the symbolic link? 6. Delete the presentation file. 7. Is there a symbolic link? If so, is the link valid? 8. Delete the symbolic link.