Useful Tools & Commands in Linux (To be updated)

Useful Tools & Commands in Linux (To be updated)

There are many useful tools in Linux to help us to explore the world. However, different from graphic tools, they are in fact some instructions in Linux, which motivates me to record some of them here, for sharing and my poor memory.

strace

Strace is a tool to help us to know what system calls are called when we run an instruction. It's usage is simple, as is shown below, we use it to get the system calls during a cat instruction.

$ strace cat foo

stat

Stat could show the informations of a file to us. For example, we use the command below to show the information of an empty file c.h (Some personal infos were erased).

$ stat c.h
  File: c.h
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fc02h/64514d    Inode: 3772845     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1002/     xxx)   Gid: ( 1002/     xxx)
Access: 2022-04-19 16:39:33.507264785 +0x00
Modify: 2021-12-12 16:46:43.353033622 +0x00
Change: 2022-04-19 16:39:42.891287534 +0x00
 Birth: -

df & du

These two commands are both used to view the size of space in your system. df shows the space information of disk and du shows that of file or directory.

The most common use of them is listed as below.

$ df -h                       # view the space of each partition
$ df -hl                      # view the available space of the disks
$ du -sh [directory name]     # view the size of the directory
$ du -h [directory name]      # view the sizes of all files in the directory

objdump

This command could be used to show the info of ELF files.

$ objdump -h {FileName}   # Display the contents of the section headers
$ objdump -d {FileName}   # Display assembler contents of executable sections
$ objdump -r {FileName}   # Display the relocation table

nm

Read the symbol table of an ELF file.

$ nm {FileName}   # read the symbol table

strip

Remove the debug info in the ELF file.

$ strip {FileName}