Linux: My Missing Manual


Some Linux commands are useful but I didn’t use it very often. Here I prepare a list to look up faster. It will be maintain and update here.

  1. cat
  2. e2fsck: Check and Repair File System
  3. find: Look for files in directories
  4. free: Check Memory Usage
  5. ifconfig: Manage Network Interface
  6. rm -rf <directory>: Remove directories and contents
  7. tar: Compress or decompress directories and contents

cat: Display files(s) Content

amigo@Edge72z:~> cat /proc/cpuinfo | grep name
model name : Intel(R) Pentium(R) CPU G630 @ 2.70GHz
model name : Intel(R) Pentium(R) CPU G630 @ 2.70GHz

cat comes from concatenate  to display a file or files. 13 Basic Cat Command Examples in Linux on TecMint.com provides great example of using cat in terminal.

Basic syntax: cat [file] [more files]

e2fsck: Check and Repair File System

Running e2.fsck in terminal when boot with OpenSuSE GNOME Live.
Running e2.fsck in terminal when boot with OpenSuSE GNOME Live.

Same as fsck -t ext4. e2fsck support ext2 / ext3 / ext4 without parameters. Need to unmount file system and switch to root before checking.

Ubuntu explain very detail as how it works:

e2fsck is used to check the ext2/ext3/ext4 family of file systems. For ext3 and ext4 filesystems that use a journal, if the system has been shut down uncleanly without any errors, normally, after replaying the committed transactions in the journal, the file system should be marked as clean. Hence, for filesystems that use journalling, e2fsck will normally replay the journal and exit, unless its superblock indicates that further checking is required.

  1. Use OpenSuSE GNOME Live to boot
  2. Use Disks to identify the name of the partition / device. It is mounted as /dev/sda1 now.
  3. In terminal, switch to root and run e2fsck -cDft /dev/sda2 to check for bad blick by reading only; optimize Directories; force checking; t to show timing.
  4. When need to auto repair (aka preen), add p in the parameters.
Using GNOME Disks to check device names.
Using GNOME Disks to check device names.

find: Look for files in directories

amigo@Edge72z:~> sudo find /etc/ -iname "php.ini"
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

find may search for matched files in assigned and its children directories.

Basic syntax: find [directory] -iname “[match pattern]”

free: Check Memory Usage

Running free in terminal on Leveno Edge 72z with 16GB RAM.
Running free in terminal on Leveno Edge 72z with 16GB RAM.

free show RAM usage information. It helps you to know how much RAM is used by system, buffers, and cache.

Use the following variables and formula to see the relationship among these numbers:

"free" output  table with variables.
“free” output table with variables.
  • a = b + c
  • f = b – ( d + e )
  • g = c + d + e

More detail explain may be found in Check your RAM usage with free in Linux. ‎

ifconfig: Manage Network Interface

ifconfig sample to display the wired, wireless, and loopback information
ifconfig sample to display the wired, wireless, and loopback information

ifconfig display detail information of your network interface. You may also use it to change IP, turn on/off network interface, change MTU, and etc.

Network Tools in GNOME provides similar features with GUI.

rm -rf <directory>: Remove directories and contents

rm -rf <directory> will remove all directories and files under the directory. Without -rf, it will only remove matched files in current directory. rmdir will remove empty directoty.

tar: Compress or decompress directories and contents

tar -cvf <directory> will compress all directories and files under the given directory.

tar -xvf <directory> will decompress all directories and files under the given directory.

tar -zcvf <directory> will compress through gzip on all directories and files under the given directory.

tar -zxvf <directory> will decompress through gzip on all directories and files under the given directory.

Reference

  1. Buffer and Cache in Hard Drive and Operating System explains the SSD Cache Size of your SSHD
  2. Check your RAM usage with free in Linux
  3. Computer Hope: How do I remove a full directory in Linux?
  4. Computer Hope: Linux and Unix free command
  5. Computer Hope: Linux and Unix tar command
  6. OpenSuSE
  7. OpenSuSE: GNOME Disks
  8. Some useful IT tips: How to check CPU(s) information on Linux
  9. TecMint.com: 13 Basic Cat Command Examples in Linux
  10. The Linux Juggernaut: Understanding free command in Linux/Unix
  11. The Will Will Web: 在 Linux 下使用 find 指令查詢目錄與檔案的速查筆記
  12. Ubuntu
  13. ubuntu manuals: e2fsck
  14. Wiki: Maximum transmission unit
  15. 鳥哥的 Linux 私房菜:ifconfig

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s