10 Useful Linux Commands
2010-01-15 08:43
477 查看
Here's a list of 10 commands that may come handy when using the command line in Linux.
Search for all files modified in the last N days containing a specific text in their name
For example:
will display all the files modified in the past five days that include the text 'log' in their filename.
Determine which processes use the most memory
will show the first 10 processes that use the most memory, using ascendant sorting. Alternately:
Figure 1: Output of ps aux | sort -nrk 4 | head
will show the first 10 processes using most memory, using descendent sorting (see Figure 1).
Display the username which is currently logged in
Show date using format modifiers
Figure 2: Showing date in format month, day, year
will
output time in format HOUR:MINUTE:SECOND. You can use any format
specifiers explained in the man page. The double quotes are required in
case you need to use spaces (see Figure 2).
Figure 3: Output of finger $USER
Show info about a specific user
Show disk usage separately for each partition
The -h switch will tell df to show human-readable sizes (KB, MB, and GB when it is the case)
will show sizes in kilobytes.
Show which modules are loaded
Add or remove a module to/from the Linux kernel
Search for a file using locate
will search the locate database (created with updatedb) for any path or file which contains FILENAME.
Change the encoding of a text file
For example:
will change the encoding of myfile.txt from ISO-8859-16 (Romanian) to UTF-8.
This article originally appeared on TuxArena
.
Search for all files modified in the last N days containing a specific text in their name
find DIR -mtime -N -name "*TEXT*"
For example:
find ~ -mtime -5 -name "*log*"
will display all the files modified in the past five days that include the text 'log' in their filename.
Determine which processes use the most memory
ps aux | sort -nk 4 | tail
will show the first 10 processes that use the most memory, using ascendant sorting. Alternately:
ps aux | sort -nrk 4 | head
Figure 1: Output of ps aux | sort -nrk 4 | head
will show the first 10 processes using most memory, using descendent sorting (see Figure 1).
Display the username which is currently logged in
whoami
Show date using format modifiers
date +"%H:%M:%S"
Figure 2: Showing date in format month, day, year
will
output time in format HOUR:MINUTE:SECOND. You can use any format
specifiers explained in the man page. The double quotes are required in
case you need to use spaces (see Figure 2).
Figure 3: Output of finger $USER
Show info about a specific user
finger $USER
Show disk usage separately for each partition
df -h
The -h switch will tell df to show human-readable sizes (KB, MB, and GB when it is the case)
df -B 1K
will show sizes in kilobytes.
Show which modules are loaded
lsmod
Add or remove a module to/from the Linux kernel
modprobe MODULE modprobe -r MODULE
Search for a file using locate
locate FILENAME
will search the locate database (created with updatedb) for any path or file which contains FILENAME.
Change the encoding of a text file
iconv -f INITIAL_ENCODING -t DESIRED_ENCODING filename
For example:
iconv -f ISO-8859-16 -t UTF-8 myfile.txt
will change the encoding of myfile.txt from ISO-8859-16 (Romanian) to UTF-8.
This article originally appeared on TuxArena
.
相关文章推荐
- Linux_10 Useful “IP” Commands to Configure Network Interfaces
- Linux_10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Dir
- Some useful Linux Commands
- Useful Linux Wireless Commands
- 30 Useful Linux Commands for System Administrators(这些命令均可以在centos服务器上运行)
- Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies
- 20 Useful Commands for Linux Newbies
- Find the Top 10 commands in your linux box!
- The useful commands in linux
- some useful Linux commands
- 20 Useful Commands for Linux Newbies
- 10 Useful Sar (Sysstat) Examples for UNIX / Linux Performance Monitoring
- Linux_12 Useful “df” Commands to Check Disk Space in Linux
- Some useful linux commands
- linux useful commands
- Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies
- Useful Linux commands from OSSIE
- useful linux commands for me
- 10 Pretty Linux Commands
- some useful linux commands