Monday, November 28, 2016

Linux: Chapter8: File Operations


"Sometimes we no need to explain, just take a look at pictures and you will conceive"
********************  Special Thanks ********************
R. Gordon
***************************************************


SECTION 1 Command Line Mode
54 68 65 20 46 69 6C 65 73 79 73 74 65 6D 20 48 69 65 72 61 72 63 68 79 20 53 74 61 6E 64 61 72 64 20 28 46 48 53 29 20 67 72 65 77 20 6F 75 74 20 6F 66 20 68 69 73 74 6F 72 69 63 61 6C 20 73 74 61 6E 64 61 72 64 73 20 66 72 6F 6D 20 65 61 72 6C 79 20 76 65 72 73 69 6F 6E 73 20 6F 66 20 55 4E 49 58 2C 20 73 75 63 68 20 61 73 20 74 68 65 20 42 65 72 6B 65 6C 65 79 20 53 6F 66 74 77 61 72 65 20 44 69 73 74 72 69 62 75 74 69 6F 6E 20 28 42 53 44 29 20 61 6E 64 20 6F 74 68 65 72 73 2E 20 54 68 65 20 46 48 53 20 70 72 6F 76 69 64 65 73 20 4C 69 6E 75 78 20 64 65 76 65 6C 6F 70 65 72 73 20 61 6E 64 20 73 79 73 74 65 6D 20 61 64 6D 69 6E 69 73 74 72 61 74 6F 72 73 20 77 69 74 68 20 61 20 73 74 61 6E 64 61 72 64 20 64 69 72 65 63 74 6F 72 79 20 73 74 72 75 63 74 75 72 65 20 66 6F 72 20 74 68 65 20 66 69 6C 65 73 79 73 74 65 6D 2C 20 77 68 69 63 68 20 70 72 6F 76 69 64 65 73 20 63 6F 6E 73 69 73 74 65 6E 63 79 20 62 65 74 77 65 65 6E 20 73 79 73 74 65 6D 73 20 61 6E 64 20 64 69 73 74 72 69 62 75 74 69 6F 6E 73 2E 0A 4C 69 6E 75 78 20 73 75 70 70 6F 72 74 73 20 76 61 72 69 6F 75 73 20 66 69 6C 65 73 79 73 74 65 6D 20 74 79 70 65 73 20 63 72 65 61 74 65 64 20 66 6F 72 20 4C 69 6E 75 78 2C 20 61 6C 6F 6E 67 20 77 69 74 68 20 63 6F 6D 70 61 74 69 62 6C 65 20 66 69 6C 65 73 79 73 74 65 6D 73 20 66 72 6F 6D 20 6F 74 68 65 72 20 6F 70 65 72 61 74 69 6E 67 20 73 79 73 74 65 6D 73 20 73 75 63 68 20 61 73 20 57 69 6E 64 6F 77 73 20 61 6E 64 20 4D 61 63 4F 53 2E 20 4D 61 6E 79 20 6F 6C 64 65 72 2C 20 6C 65 67 61 63 79 20 66 69 6C 65 73 79 73 74 65 6D 73 2C 20 73 75 63 68 20 61 73 20 46 41 54 2C 20 61 72 65 20 73 75 70 70 6F 72 74 65 64 2E
Some examples of filesystem types that Linux supports are:
  • ext3, ext4, btrfsxfs (native Linux filesystems)
  • vfatntfs, hfs (filesystems from other operating systems)
 /etc/fstab shows disk UUID
mount shows everything
df -Th  shows additional Type

4E 46 53 20 28 74 68 65 20 4E 65 74 77 6F 72 6B 20 46 69 6C 65 73 79 73 74 65 6D 29 20 69 73 20 6F 6E 65 20 6F 66 20 74 68 65 20 6D 65 74 68 6F 64 73 20 75 73 65 64 20 66 6F 72 20 73 68 61 72 69 6E 67 20 64 61 74 61 20 61 63 72 6F 73 73 20 70 68 79 73 69 63 61 6C 20 73 79 73 74 65 6D 73 2E 20 4D 61 6E 79 20 73 79 73 74 65 6D 20 61 64 6D 69 6E 69 73 74 72 61 74 6F 72 73 20 6D 6F 75 6E 74 20 72 65 6D 6F 74 65 20 75 73 65 72 73 27 20 68 6F 6D 65 20 64 69 72 65 63 74 6F 72 69 65 73 20 6F 6E 20 61 20 73 65 72 76 65 72 20 69 6E 20 6F 72 64 65 72 20 74 6F 20 67 69 76 65 20 74 68 65 6D 20 61 63 63 65 73 73 20 74 6F 20 74 68 65 20 73 61 6D 65 20 66 69 6C 65 73 20 61 6E 64 20 63 6F 6E 66 69 67 75 72 61 74 69 6F 6E 20 66 69 6C 65 73 20 61 63 72 6F 73 73 20 6D 75 6C 74 69 70 6C 65 20 63 6C 69 65 6E 74 20 73 79 73 74 65 6D 73 2E 20 54 68 69 73 20 61 6C 6C 6F 77 73 20 74 68 65 20 75 73 65 72 73 20 74 6F 20 6C 6F 67 20 69 6E 20 74 6F 20 64 69 66 66 65 72 65 6E 74 20 63 6F 6D 70 75 74 65 72 73 20 79 65 74 20 73 74 69 6C 6C 20 68 61 76 65 20 61 63 63 65 73 73 20 74 6F 20 74 68 65 20 73 61 6D 65 20 66 69 6C 65 73 20 61 6E 64 20 72 65 73 6F 75 72 63 65 73 2E




/proc/cpuinfo  looks like CPUz program
/proc/interrupts shows all Cores info
/proc/meminfo shows all about mem, buffer, cache

kevin@phoenix:/proc$ cat partitions 

major minor  #blocks  name
20 20 20 38 20 20 20 20 20 20 20 20 30 20 20 34 38 38 33 38 36 35 38 34 20 73 64 61 0A 20 20 20 38 20 20 20 20 20 20 20 20 31 20 20 20 20 20 31 30 32 34 30 30 20 73 64 61 31 0A 20 20 20 38 20 20 20 20 20 20 20 20 32 20 20 32 37 35 32 37 39 38 37 32 20 73 64 61 32 0A 20 20 20 38 20 20 20 20 20 20 20 20 33 20 20 32 31 33 30 30 32 32 34 30 20 73 64 61 33
kevin@phoenix:/proc$ 




kevin@phoenix:/proc$ cat version

Linux version 4.3.0-kali1-amd64 (debian-kernel@lists.debian.org) (gcc version 5.3.1 20160101 (Debian 5.3.1-5) ) #1 SMP Debian 4.3.3-5kali4 (2016-01-13)

kevin@phoenix:/proc$ 

kevin@phoenix:/proc$ uname -a

Linux phoenix 4.3.0-kali1-amd64 #1 SMP Debian 4.3.3-5kali4 (2016-01-13) x86_64 GNU/Linux
kevin@phoenix:/proc$ 

             -type c
              File is of type c:
              b      block (buffered) special
              c      character (unbuffered) special
              d      directory
              p      named pipe (FIFO)
              f      regular file
              l      symbolic  link;  this  is  never  true  if the -L option or the -follow option is in effect, unless the symbolic link is broken.  If  you  want to search for symbolic links when -L is in effect, use -xtype.
              s      socket
              D     door (Solaris)

This one made me wonder why it couldn't xargs tail -f?


Notice: please check arrow sign with 1st file and 2nd file




Directory nameUsage
/optOptional application software packages.
/sysVirtual pseudo-filesystem giving information about the system and the hardware. Can be used to alter system parameters and for debugging purposes. 
/srvSite-specific data served up by the system. Seldom used.
/tmpTemporary files; on some distributions erased across a reboot and/or may actually be a ramdisk in memory.
/usrMulti-user applications, utilities and data.
Directory nameUsage
/usr/includeHeader files used to compile applications.
/usr/libLibraries for programs in /usr/bin and /usr/sbin.
/usr/lib6464-bit libraries for 64-bit programs in /usr/bin and /usr/sbin.
/usr/sbinNon-essential system binaries, such as system daemons.
/usr/shareShared data used by applications, generally architecture-independent.
/usr/srcSource code, usually for the Linux kernel.
/usr/X11R6X Window configuration files; generally obsolete.
/usr/localData and programs specific to the local machine. Subdirectories include bin, sbin, lib, share, include, etc.
/usr/binThis is the primary directory of executable commands on the system. 


Disk-to-Disk Copying
54 68 65 20 64 64 20 70 72 6F 67 72 61 6D 20 69 73 20 76 65 72 79 20 75 73 65 66 75 6C 20 66 6F 72 20 6D 61 6B 69 6E 67 20 63 6F 70 69 65 73 20 6F 66 20 72 61 77 20 64 69 73 6B 20 73 70 61 63 65 2E 20 46 6F 72 20 65 78 61 6D 70 6C 65 2C 20 74 6F 20 62 61 63 6B 20 75 70 20 79 6F 75 72 20 4D 61 73 74 65 72 20 42 6F 6F 74 20 52 65 63 6F 72 64 20 28 4D 42 52 29 20 28 74 68 65 20 66 69 72 73 74 20 35 31 32 20 62 79 74 65 20 73 65 63 74 6F 72 20 6F 6E 20 74 68 65 20 64 69 73 6B 20 74 68 61 74 20 63 6F 6E 74 61 69 6E 73 20 61 20 74 61 62 6C 65 20 64 65 73 63 72 69 62 69 6E 67 20 74 68 65 20 70 61 72 74 69 74 69 6F 6E 73 20 6F 6E 20 74 68 61 74 20 64 69 73 6B 29 2C 20 79 6F 75 20 6D 69 67 68 74 20 74 79 70 65 3A 0A 0A 64 64 20 69 66 3D 2F 64 65 76 2F 73 64 61 20 6F 66 3D 73 64 61 2E 6D 62 72 20 62 73 3D 35 31 32 20 63 6F 75 6E 74 3D 31 0A 0A 54 6F 20 75 73 65 20 64 64 20 74 6F 20 6D 61 6B 65 20 61 20 63 6F 70 79 20 6F 66 20 6F 6E 65 20 64 69 73 6B 20 6F 6E 74 6F 20 61 6E 6F 74 68 65 72 2C 20 28 57 41 52 4E 49 4E 47 21 29 20 64 65 6C 65 74 69 6E 67 20 65 76 65 72 79 74 68 69 6E 67 20 74 68 61 74 20 70 72 65 76 69 6F 75 73 6C 79 20 65 78 69 73 74 65 64 20 6F 6E 20 74 68 65 20 73 65 63 6F 6E 64 20 64 69 73 6B 2C 20 74 79 70 65 3A 0A 0A 64 64 20 69 66 3D 2F 64 65 76 2F 73 64 61 20 6F 66 3D 2F 64 65 76 2F 73 64 62 0A 0A 41 6E 20 65 78 61 63 74 20 63 6F 70 79 20 6F 66 20 74 68 65 20 66 69 72 73 74 20 64 69 73 6B 20 64 65 76 69 63 65 20 69 73 20 63 72 65 61 74 65 64 20 6F 6E 20 74 68 65 20 73 65 63 6F 6E 64 20 64 69 73 6B 20 64 65 76 69 63 65 2E 0A 0A 44 6F 20 6E 6F 74 20 65 78 70 65 72 69 6D 65 6E 74 20 77 69 74 68 20 74 68 69 73 20 63 6F 6D 6D 61 6E 64 20 61 73 20 77 72 69 74 74 65 6E 20 61 62 6F 76 65 20 61 73 20 69 74 20 63 61 6E 20 65 72 61 73 65 20 61 20 68 61 72 64 20 64 69 73 6B 21 0A 0A 45 78 61 63 74 6C 79 20 77 68 61 74 20 74 68 65 20 6E 61 6D 65 20 64 64 20 73 74 61 6E 64 73 20 66 6F 72 20 69 73 20 61 6E 20 6F 66 74 65 6E 2D 61 72 67 75 65 64 20 69 74 65 6D 2E 20 54 68 65 20 77 6F 72 64 73 20 64 61 74 61 20 64 65 66 69 6E 69 74 69 6F 6E 20 69 73 20 74 68 65 20 6D 6F 73 74 20 70 6F 70 75 6C 61 72 20 74 68 65 6F 72 79 20 61 6E 64 20 68 61 73 20 72 6F 6F 74 73 20 69 6E 20 65 61 72 6C 79 20 49 42 4D 20 68 69 73 74 6F 72 79 2E 20 4F 66 74 65 6E 20 70 65 6F 70 6C 65 20 6A 6F 6B 65 20 74 68 61 74 20 69 74 20 6D 65 61 6E 73 20 64 69 73 6B 20 64 65 73 74 72 6F 79 65 72 20 61 6E 64 20 6F 74 68 65 72 20 76 61 72 69 61 6E 74 73 20 73 75 63 68 20 61 73 20 64 65 6C 65 74 65 20 64 61 74 61 21

↞ Summary ↠
The key concepts covered in this chapter are:
  • The filesystem tree starts at what is often called the root directory (or trunk, or /).
  • The Filesystem Hierarchy Standard (FHS) provides Linux developers and system administrators a standard directory structure for the filesystem.
  • Partitions help to segregate files according to usage, ownership and type.
  • Filesystems can be mounted anywhere on the main filesystem tree at a mount point. Automatic filesystem mounting can be set up by editing /etc/fstab.
  • NFS (The Network Filesystem) is a useful method for sharing files and data through the network systems.
  • Filesystems like /proc are called pseudo filesystems because they exist only in memory.
  • /root (slash-root) is the home directory for the root user.
  • /var may be put in its own filesystem so that growth can be contained and not fatally affect the system.
  • /boot contains the basic files needed to boot the system
  • patch is a very useful tool in Linux. Many modifications to source code and configuration files are distributed with patch files as they contain the deltas or changes to go from an old version of a file to the new version of a file.
  • File extensions in Linux do not necessarily mean that a file is of a certain type.
  • cp is used to copy files on the local machine while rsync can also be used to copy files from one machine to another as well as synchronize contents.
  • gzipbzip2xz and zip are used to compress files.
  • tar allows you to create or extract files from an archive file, often called a tarball. You can optionally compress while creating the archive, and decompress while extracting its contents
  • dd  can be used to make large exact copies even of entire disk partitions efficiently

Of course, I am an Artist~

Reference:
https://www.linuxfoundation.org
JAYz - { KevinChen 陳爱平}


No comments:

Post a Comment