10 useful Linux commands

Source: Internet
Author: User

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

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
.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.