Most viewed posts
LINUX COMMANDS
Search
File system
Linux Command: dpkg-query
dpkg-query - a tool to query the dpkg database
Linux Command Options:
dpkg-query [option...] command
dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n List all packages by installed size (KBytes) on deb distros
Linux Command: sort
sort [options] [files]
Sort the lines of the named files. Compare specified fields for each pair of lines; if no fields are specified, compare them by byte, in machine-collating sequence. If no files are specified or if the file is -, the input is taken from standard input. See also uniq, comm, and join.
wc -l * | sort -r List files by decreasing number of lines:
sort -fd wordlist | uniq -c Alphabetize a list of words, remove duplicates, and print the frequency of each word:
sort wordlist | uniq Sort and remove duplicates of wordlist
Linux Command: mount
mount [options] [[device] directory]
| $ mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share | Mount a windows share |
| $ mount -o loop cdrom.iso /mnt/dir | Mount the cdrom image at /mnt/dir (read only) |
| $ mount | column -t | List mounted filesystems on the system (and align output) |
Linux Command: join
join [options] file1 file2
Join lines of two sorted files by matching on a common field. If either file1 or file2 is -, read from standard input. Often used to merge data stored in text-based file formats such as comma-separated-value formatted spreadsheets.
join -t'\0' -a1 -a2 file1 file2 Union of sorted files
join -t'\0' file1 file2 Intersection of sorted files
join -t'\0' -v2 file1 file2 Difference of sorted files
join -t'\0' -v1 -v2 file1 file2 Symmetric Difference of sorted files
Linux Command: find
find [pathnames] [conditions]
An extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. The default pathname is the current directory. The most useful conditions include -name and -type (for general use), -exec and -size (for advanced use), and -mtime and -user (for administrators).
| find /work -name chapter1 | List all files named chapter1 in the /work directory |
| find /work -name 'memo*' -user ann -print | List all files beginning with memo owned by ann in the /work directory |
| gzip `find . \! -name '*.gz' -print` | Find and compress files whose names don’t end with .gz |
| find / -mtime -2 -print | Search the system for files that were modified within the last two days (good candidates for backing up) |
| find /book -print | xargs grep '[Nn]utshell' | Recursively grep for a pattern down a directory tree: |
| find -type d ! -perm -111 | Find dirs not accessible by all (useful for web site |