10 Useful Linux Commands

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

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
Output of 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"
Showing date in format month, day, year

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). 

Output of finger $USER

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 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值