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 maintained and updated here.
- e2fsck: Check and Repair File System
- find: Look for files in directories
- free: Check Memory Usage
- ifconfig: Manage Network Interface
- rm -rf <directory>: Remove directories and contents
- 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
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.
- Use OpenSuSE GNOME Live to boot
- Use Disks to identify the name of the partition / device. It is mounted as /dev/sda1 now.
- 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.
- When need to auto repair (aka preen), add p in the parameters.
find: Look for files in directories
-iname: case insensitive
$ 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]”
-name: case sensitive
Search for only current directory witout any quote is ignored.
More detail explain may be found in: Wildcards and double quotes with find -name command
$ find -name *.txt ./three.txt $ find -name "*.txt" ./three.txt ./2/two.txt ./1/one.txt
-delete: delete files
Usually used with “-iname” or “-name” to serach then delete.
$ find -name *.tmp -delete
free: Check Memory Usage
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:
- 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 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.
|Right Workspace||[Ctrl] + [Alt] + [→]|
|Left Workspace||[Ctrl] + [Alt] + [←]|
- Buffer and Cache in Hard Drive and Operating System explains the SSD Cache Size of your SSHD
- StackOverflow: Wildcards and double quotes with find -name command
- Check your RAM usage with free in Linux
- Computer Hope: How do I remove a full directory in Linux?
- Computer Hope: Linux and Unix free command
- Computer Hope: Linux and Unix tar command
- OpenSuSE: GNOME Disks
- Some useful IT tips: How to check CPU(s) information on Linux
- TecMint.com: 13 Basic Cat Command Examples in Linux
- The Linux Juggernaut: Understanding free command in Linux/Unix
- The Will Will Web: 在 Linux 下使用 find 指令查詢目錄與檔案的速查筆記
- ubuntu manuals: e2fsck
- Wiki: Maximum transmission unit
- 鳥哥的 Linux 私房菜：ifconfig