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 陳爱平}


Sunday, November 27, 2016

Linux: Chapter7: Command Line Operations


"Intangible and invisible things may be meaningful. 
Tangible and visible things might mean nothing."



********************  Special Thanks ********************

ec2-107-xx-87-xxx.compute-1.amazonaws.com

***************************************************

SECTION 1 Command Line Mode
   A terminal emulator program emulates (simulates) a stand alone terminal within a window on the desktop By default, on GNOME desktop environments, the gnome-terminal application is used to emulate a text-mode terminal in a window. Other available terminal programs include:

  • xterm
  • rxvt
  • konsole
  • terminator
xterm is used to emulate a graphical-mode terminal as I installed Oracle DBMS in Linux. 
Therefore, I think xterm, rxvt, kconsole and terminator might be the same but different Distros.


The X Window System
     Linux Distros provide both CLI and GUI. Production server should be CLI only since it's secured and lean system.



Turning off the Graphical Desktop
     Linux distributions can start and stop the graphical desktop in various ways. For Debian-based systems, the Desktop Manager runs as a service which can be simply stopped. For RPM-based systems, the Desktop Manager is run directly by init when set to run level 5; switching to a different runlevel stops the desktop.
      Use the sudo service gdm stop or sudo service lightdm stop commands, to stop the graphical user interface in Debian-based systems. On RPM-based systems typing sudo telinit 3 may have the same effect of killing the GUI. 
Remark: the killed system doesn't prompt at command line terminal. I mean, it's gone and need to power on again.
sudo vs su
  • sudo allows users to run programs using the security privileges of another user, generally root (superuser).
  • su (switch user) allows user to switch user to another one such as su - kevin
  • "su - root"  and "su" and "su -" commands switch to root user but environments are different. You might find its differences in advance. 


242066696e64202f757372202d6e616d6520224b6576696e220a0a6364202d206261636b20746f2070726576696f7573206469720a0a7075736864202e20706f70642e20666f722070757368696e6720616e6420706f7070696e672064697220696e20737461636b0a0a2f757372202d747970652066202d6e616d652074657374310a0a242066696e64202d6e616d6520222a2e73777022202d6578656320726d207b7d20273b270a0a66696e64202f202d6374696d65203320206d6f7265206f7074696f6e733d3d3e20282d636d696e2c202d616d696e2c20616e64202d6d6d696e29

I have left out many details since I have known it.
Reference:
https://www.linuxfoundation.org
JAYz - { KevinChen 陳爱平}

Saturday, November 26, 2016

Linux: Chapter6: Finding Linux Documentation




"It would be better to teach how to fishing rather than give them a fish", quoted by Anonymous.

********************  Special Thanks ********************
Her Royal Highness Princess Maha Chakri Sirindhorn,
Daughter to the Queen Regent who is citizens' idol on Technologies and Languages.
********************************************************


SECTION 1 Documentation Sources
  1. The man pages (short for manual pages)
  2. GNU Info
  3. The help command and --help option
  4. Other Documentation Sources, e.g. https://www.gentoo.org/doc/en/http://directory.fsf.org/wiki/Main_Page
                     man –f ~= whatis                   short description what it does, -f = fast (how to remember)
                     man –k ~= apropos               lists all things related to specific topic. -k = king (the king is a man who holds all things. technique to remember for me )

SECTION 2 GNU info
To install this command: sudo apt-get install info
          After go into info grep document, above pictures show you when pressing "N" or "Next". It means, go to next "Node"
         Notice: Next, Prev and Up at the top line of the console. I mean, we can press N, P and U as it mentioned.
SECTION 3 help command: -h or --help

SECTION 4 Other Documentation Sources
     In addition to the man pages, the GNU Info System, and the help command, there are other sources of Linux documentation, some examples of which are shown here.








Desktop Help Systems
        All Linux desktop systems have a graphical help application. This application is usually displayed as a question-mark icon or an image of a ship’s life-preserver. These programs usually contain custom help for the desktop itself and some of its applications, and will often also include graphically rendered info and man pages.

Warning: Sometimes sources might make a mistake. You have to work around and I found that Debian-based might use khelpcenter NOT gnome-help as shown below.
You can also start the graphical help system from a graphical terminal using the following commands:
  • GNOMEgnome-help 
  • KDE: khelpcenter




↞ Summary ↠
    • The main sources of Linux documentation are the man pages, GNU Info, the help options and command, and a rich variety of online documentation sources. 
    • The man utility searches, formats, and displays man pages.
    • The man pages provide in-depth documentation about programs and other topics about the system including configuration files, system calls, library routines, and the kernel.
    • The GNU Info System was created by the GNU project as its standard documentation. It is robust and is accessible via command line, web, and graphical tools using info.
    • Short descriptions for commands are usually displayed with the -h or --help argument.
    • You can type help at the command line to display a synopsis of built-in commands.
    • There are many other help resources both on your system and on the Internet.

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