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*"
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
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
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).¬†
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)
df -B 1K
will show sizes in kilobytes.
Show which modules are loaded
Add or remove a module to/from the Linux kernel
modprobe -r MODULE
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
iconv -f INITIAL_ENCODING -t DESIRED_ENCODING filename
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.