Shortcut and Command Linux

<CTRL><ALT><F1>
Switch to the first text terminals. Under Linux you can have several (6 in standard setup) terminals opened at the same time. This is a keyboard shortcut, which means: "press the control key and the alt key, hold them. Now press <F1>. Release all keys."
<Ctrl><Alt><Fn> (n=1..6)
Switch to the nth text terminal. (The same could be accomplished with the rarely used command chvt n. "chvt" stands for "change virtual terminal"). In text terminal (outside X), you can also use <Alt><Fn> (the key <Ctrl> is not needed).
tty
Print the name of the terminal in which you are typing this command. If you prefer the number of the active terminal (instead of its name), it can be printed using the command fgconsole(="foreground console").
<Ctrl><Alt><F7>
Switch to the first GUI terminal (if X-windows is running on the 7th terminal, where it typcially is).
<Ctrl><Alt><Fn> (n=7..12)
Switch to the nth GUI terminal (if a GUI terminal is running on screen n-1). On default, the first X server is running on terminal 7. On default, nothing is running on terminals 8 to 12--you can start subsequent X server there.
<Tab>
(In a text or X terminal) Autocomplete the command if there is only one option, or else show all the available options. On newer systems you may need to press <Tab><Tab>. THIS SHORTCUT IS GREAT, it can truely save you lots of time.
<ArrowUp>
(In a text or X terminal) Scroll and edit the command history. Press<Enter> to execute a historical command (to save on typing).<ArrowDown> scrolls back.
<Shift><PgUp>
Scroll terminal output up. This works also at the login prompt, so you can scroll through your bootup messages. The amount/usage of your video memory determines how far back you can scroll the display. <Shift><PgDown> scrolls the terminal output down.
<Ctrl><Alt><+>
(in X-windows) Change to the next X-server resolution (if you set up the X-server to more than one resolution). For multiple resolutions on my standard SVGA card/monitor, I have the following line in the file /etc/X11/XF86Config (the first resolution starts on default, the largest resolution determines the size of the "virtual screen"):
Modes "1024x768" "800x600" "640x480" "512x384" "480x300" "400x300" "1152x864"Z
Of course, first I had to configure the X server, either by using Xconfigurator, xf86config, or manually by edition the file/etc/X11/XF86Config, so that it supports the above resolutions (mostly the matter of uncommenting the line that defines my video chipset, and specifying the synchronization frequencies my monitor supports). XFdrake (Mandrake configuration utility) can do it from GUI. See also the commands xvidtune and xvidgen.
<Ctrl><Alt><->
(in X-windows) Change to the previous X-server resolution.
<Ctrl><Alt><Esc>
(in X-windows, KDE) Kill the window I am going to click with my mouse pointer (the pointer changes to something like a death symbol). Similar result can be obtained with the command xkill (typed in X-terminal). Useful when an X-window program does not want to close (hangs?).
<Ctrl><Alt><BkSpc>
(in X-windows) Kill the current X-windows server. Use if the X-windows server cannot be exited normally.
<Ctrl><Alt><Del>
(in text terminal) Shut down the system and reboot. This is the normal shutdown command for a user at the text-mode console. Don't just press the "reset" button for shutdown!
<Ctrl>c
Kill the current process (works mostly with small text-mode applications).
<Ctrl>d
(pressed at the beginning of an empty line) Log out from the current terminal. See also the next command.
<Ctrl>d
Send [End-of-File] to the current process. Don't press it twice else you also log out (see the previous command).
<Ctrl>s
Stop the transfer to the terminal.
<Ctrl>q
Resume the transfer to the terminal. Try if your terminal mysteriously stops responding. See the previous command.
<Ctrl>z
Send the current process to the background.
exit
Logout. I can also use logout for the same effect. (If you have started a second shell, e.g., using bash, this command will make you exit the second shell, and you will be back in the first shell, not logged out. Then use another exit to logout.)
reset
Restore a screwed-up terminal (a terminal showing funny characters) to default setting. Use if you tried to "cat" a binary file. You may not be able to see the command as you type it, but it still will work.
<MiddleMouseButton>
Paste the text which is currently highlighted somewhere else. This is the normal "copy-paste" operation in Linux. It a fast and powerful supplement to the widely-known GUI "copy-paste" menu-based operation. (It doesn't work inside older versions of Netscape which use the Mac/MS Windows-style "copy-paste" exclusively. It does work in the text terminal if you enabled "gpm" service using "setup". It also works inside any dialog boxes, etc.--really convenient!) It is best used with a Linux-ready 3-button mouse (Logitech or similar) or else set "3-mouse button emulation". The <MiddleMouseButton> is normally emulated on a 2-button mouse by pressing both mouse buttons simultanously.
~
(tilde character) My home directory (normally the directory/home/my_login_name). For example, the command cd ~/my_dir will change my working directory to the subdirectory "my_dir" under my home directory. Typing just "cd" alone is an equivalent of the command "cd ~". I keep all my files in my home directory.
.
(dot) Current directory. For example, ./my_program will attempt to execute the file "my_program" located in your current working directory.
..
(two dots) Directory parent to the current one. For example, the command cd .. will change my current working directory one one level up.
Some additional KDE keyboard shortcuts (useful, but non-essential)
<Alt><Tab> Walk through windows. To walk backwards: <Alt><Shift><Tab>
<Ctrl><Tab> Walk through desktops. To walks backwards:<Ctrl><Shift><Tab>
<Ctrl><Esc> Show the table of processes running on my system. Allow me to kill any of the processes I started (or send other signals to them).
<Alt><F1> Access the K-menu ("Equivalent to MS Windows "Start" menu).
<Alt><F12> Emulate the mouse using the arrow keys on the keyboard.
<Alt><LeftMouseButton> Drag a window to move it. Normally, I move a window by dragging its top title bar, but occassionally I manage to get it off the screen. With this shortcut, I can drag by any part of the window.
<Alt><PrintScreen> Take a snapshot of the current window into the clipboard.
<Ctrl><Alt><PrintScreen> Take a snapshot of the entire desktop into the clipboard.
<Ctrl><Alt><l> Lock the desktop.
<Ctrl><Alt><d> Toggle hide/show the desktop (great to hide the Solitaire game when your boss walks in).
<Alt><SysRq>
(Non-essential.) This is a group of key combinations implemented at the Linux kernel level (a low level). It means, chances are these key combinations will work most of the time. The combinations are meant for debugging purposes and in an emergency (mostly developers); you should try other, safer solutions first. The key <SysRq> is also knows on PC as <PrintScreen>. The combinations can be enabled/disabled by setting the relevant kernel variable to "1" or "0", e.g. : echo "1" > /proc/sys/kernel/sysrq
<Alt><SysRq><k> Kill all processes (including X) which are running on the currently active virtual console. This key combination is know as "secure access key" (SAK).
<Alt><SysRq><e> Send the TERM signal to all running processes except init, asking them to exit.
<Alt><SysRq><i> Send the KILL signal to all running processes except init. This may be more successful in killing runaway processes than the previous key combination, but it may cause some of them to exit abnormally.
<Alt><SysRq><l> Send the KILL signal to all processes, including init. The system will not be functional.
<Alt><SysRq><s> Run an emergency sync (cache write) on all mounted filesystems. This can prevent data loss.
<Alt><SysRq><u> Remount all mounted filesystems as read-only. This has the same effect as the sync combination above, but with one important benefit: if the operation is successful, fsck won't have to check all filesystems after a computer hardware reset.
<Alt><SysRq><r> Turn off keyboard raw mode. This can be useful when your X session hangs. After issueing this command you may be able to use <Ctrl><Alt><Del>.
<Alt><SysRq><b> Reboot immediately without syncing or unmounting your disks. Your will likely end up with filesystem errors.
<Alt><SysRq><o> Shut the system off (if configured and supported).
<Alt><SysRq><p> Dump the current registers and flags to your console.
<Alt><SysRq><t> Dump a list of current tasks and their information to your console.
<Alt><SysRq><m> Dump memory info to your console.
<Alt>SysRq><digit> The digit is '0' to '9'. Set the console log level, controlling which kernel messages will be printed to your console. For example, '0' will cause only emergency messages like PANICs or OOPSes displayed on your console.
<Alt><SysRq><h> Display help. Also, any other unsupported <Alt><SysRq><key> combination will display the same help
.

***Any_command --help |more 
Display a brief help on a command (works with most commands). For example, try cp --help |more. "--help" works similar to DOS "/h" switch. The "more" pipe is needed when the output is longer than one screen.

man topic
Display the contents of the system manual pages (help) on the topic. Press "q" to quit the viewer. Try man man if you need any advanced options. The command info topic works similar to man topic, yet it may contain more up-to-date information. Manual pages can be hard to read--they were written for UNIX programmers. Try any_command--help for a brief, easier to digest help on a command. Some programs also come with README or other info files--have a look to the directory /usr/share/doc. To display manual page from a specific section, I may use something like: man 3 exit (this displays an info on the command exit from section 3 of the manual pages) or man -a exit (this displays man pages for exit from all sections). The man sections are: Section 1-User Commands, Section 2-System Calls, Section 3-Subroutines, Section 4-Devices, Section 5-File Formats, Section 6-Games, Section 7-Miscellaneous, Section 8-System Administration, Section 9, Section n-New. To print a manual page, I use: man topic | col -b | lpr (the option col -b removes any backspace or other characters that could make the printed manpage difficult to read).
info topic
Display the contents of the info on a particular command. info is a replacement for man pages so it contains the most recent updates to the system documentation. Use and to move around or you may get confused. Press "q" to quit. A replacement for the somewhat confusing info browsing system might be pinfo - try if you like it any better.
apropos topic
Give me the list of the commands that have something to do with my topic.
whatis topic
Give me a short list of commands matching my topic. whatis is similar to apropos (see the command above)--they both use the same database. But whatis searches keywords, while aproposalso searches the descriptions of the keywords.
help command
Display brief info on a bash (shell) built-in command. Using helpwith no command prints the list of all bash built-in commands. The shortest list of bash built-in commands would probably include:alias, bg, cd, echo, exit, export, fg, help, history, jobs, kill, logout, pwd, set, source, ulimit, umask, unalias, unset.
kdehelp
kdehelpcenter
(in X-terminal, two commands, use the one that works on your system). Browse the whole system help using the graphical KDE help navigator. Normally, KDE help is invoked by pressing the appropriate icon on the KDE control panel. Use gnome-help-browser for the GNOME equivalent.


***System info
PWD
Print working directory, i.e., display the name of my current directory on the screen.
hostname
Print the name of the local host (the machine on which I am working). Usenetconf (as root) to change the name of the machine.
whoami
Print my login name.
id username
Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.
date
Print the operating system current date, time and timezone. For an ISO standard format, I have to use: date -Iseconds
I can change the date and time to 2000-12-31 23:57 using this command: date 123123572000
or using these two commands (easier to remember):
date --set 2000-12-31
date --set 23:57:00
To set the hardware (BIOS) clock from the system (Linux) clock, I can use the command (as root): setclock
The international (ISO 8601) standard format for all-numeric date/time has the form: 2001-01-31 (as in Linux default "C" localization). You can be more precise if you wish using, for example: 2001-01-31 23:59:59.999-05:00 (representing I milisecond before February 2001, in a timezone which is 5 hours behind the Universal Coordinated Time (UTC)) . The most "kosher" representation of the same point in time could be: 20010131T235959,999-0500. See the standard at ftp://ftp.qsl.net/pub/g1smd/8601v03.pdf.
time
Determine the amount of time that it takes for a process to complete + other process accounting. Don't confuse it with the datecommand (see previous entry). E.g. I can find out how long it takes to display a directory content using: time ls. Or I can test the time function with time sleep 10 (time the commands the does nothing for 10 seconds).

clock
hwclock
(two commands, use either). Obtain date/time from the computer hardware (real time, battery-powered) clock. You can also use one of this commands to set the hardware clock, but setclock may be simplier (see 2 commands above). Example: hwclock --systohc --utc sets the hardware clock (in UTC) from the system clock.
who
Determine the users logged on the machine.
w
Determine who is logged on the system, find out what they are doing, their processor ussage, etc. Handy security command.
rwho -a
(=remote who) Determine users logged on other computers on your network. The rwho service must be enabled for this command to run. If it isn't, run setup (RedHat specific) as root to enable "rwho".
finger user_name
System info about a user. Try: finger root . One can use fingerwith any networked computer that exposes the finger service to the world, e.g., I can do (try): finger @finger.kernel.org
last
Show listing of users last logged-in on your system. Really good idea to check it from time to time as a security measure on your system.
lastb
("=last bad") Show the last bad (unsuccessful) login attempts on my system. It did not work on my system, so got it started with: touch /var/log/btmp
"There's a good reason why /var/log/btmp isn't available on any sane set-up - it's a world-readable file containing login mistakes. Since one of the most common login mistakes is to type the password instead of the username, /var/log/btmp is a gift to crackers." (Thanks to Bruce Richardson). It appears the problem can be solved by changing the file permissions so only root can use "lastb": 
chmod o-r /var/log/btmp
history | more
Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful. To see what another user was doing on your system, login as "root" and inspect his/her "history". The history is kept in the file .bash_history in the user home directory (so yes, it can be modified or erased).

uptime
Show the amount of time since the last reboot.
ps
(="print status" or "process status") List the processes currently run by the current user.
ps axu | more
List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.
top
Keep listing the currently running processes on my computer, sorted by cpu usage (top processes first). Press c when done.
PID = process identification. 
USER=name of the user who owns (started?) the process.
 
PRI=priority of the process (the higher the number, the lower the priority, normal 0, highest priority is -20, lowest 20.
 
NI=niceness level (i.e., if the process tries to be nice by adjusting the priority by the number given). The higher the number, the higher the niceness of the process (i.e., its priority is lower).
 
SIZE=kilobytes of code+data+stack taken by the process in memory.

RSS=kilobytes of physical (silicon) memory taken.
 
SHARE=kilobytes of memory shared with other processes.
 
STAT=state of the process: S-sleeping, R-running, T-stopped or traced, D-uniterruptable sleep, Z=zombie.
 
%CPU=share of the CPU usage (since last screen update).
 
%MEM=share of physical memory.
 
TIME=total CPU time used by the process (since it was started).
 
COMMAND=command line used to start the task (careful with passwords, etc., on command line, all permitted to run "top" may see them!
gtop
ktop
(in X terminal) Two GUI choices for top. My favourite is gtop (comes with gnome). In KDE, ktop is also available from the "K"menu under "System"-"Task Manager".

uname -a
(= "Unix name" with option "all") Info on your (local) server. I can also use guname (in X-window terminal) to display the info more nicely.
XFree86 -version
Show me the version of X windows I have on my system.
cat /etc/issue
Check what distribution you are using. You can put your own message in this text file--it's displayed on login. It is more common to put your site-specific login message to the file /etc/motd("motd"="message of the day").
free
Memory info (in kilobytes). "Shared" memory is the memory that can be shared between processes (e.g., executable code is "shared"). "Buffered" and "cashed" memory is the part that keeps parts of recently accessed files--it can be shrunk if more memory is needed by processes.
df -h
(=disk free) Print disk info about all the filesystems (in human-readable form).
du / -bh | more
(=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form).
cat /proc/cpuinfo
Cpu info--it shows the content of the file cpuinfo. Note that the files in the /proc directory are not real files--they are hooks to look at information available to the kernel.
cat /proc/interrupts
List the interrupts in use. May need to find out before setting up new hardware.
cat /proc/version
Linux version and other info.
cat /proc/filesystems
Show the types of filesystems currently in use.
cat /etc/printcap |more
Show the setup of printers.
lsmod
(= "list modules". As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.
set|more
Show the current user environment (in full). Normally too much to bother.
echo $PATH
Show the content of the environment variable "PATH". This command can be used to show other environment variables as well. Use set to see the full environment (see the previous command).
dmesg | less
Print kernel messages (the content of the so-called kernel ring buffer). Press "q" to quit "less". Use less /var/log/dmesg to see what "dmesg" dumped into this file right after the last system bootup.
chage -l my_login_name
See my password expiry information.
quota
See my disk quota (the limits of disk usage).
sysctl -a |more
Display all the configurable Linux kernel parameters.
runlevel
Print the previous and current runlevel. The output "N5" means: "no previous runlevel" and "5 is the current runlevel". To change the runlevel, use "init", e.g., init 1 switches the system to a single user mode.
Runlevel is the mode of operation of Linux. Runlevel can be switched "on the fly" using the command init. For example, init 3 (as root) will switch me to runlevel 3. The following runlevels are standard: 
0 - halt (Do NOT set initdefault to this)
 
1 - Single user mode
 
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
 
3 - Full multiuser mode
 
4 - unused
 
5 - X11
 
6 - reboot (Do NOT set initdefault to this)
 
The system default runlevel is set in the file: /etc/inittab .
sar
View information extracted the system activity log file (/var/log/sarxx where xx is the current day number). sar can extract many kinds of system statistics including CPU load averages, i/o statistics, and network trafic statistics for the current day and (usually) several days backs.

ls 
dir
List the contents of the current directory. The command dir is an alias to ls so these two commands do exactly the same thing. The file listing is normally color-coded: dark blue= directories, light grey = regular files, green = executable files, magenta = graphics files, red = compressed (zipped) files, light blue = symbolic links, yellow = device files, brown = FIFO ("First-In First-Out" named pipes).

ls -al |more
List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the "more" command, so that the display pauses after each screenful. The lscommand has several very useful options. Some of these may have shortcuts (aliases) to avoid clumsy typing. Try ll (="long ls", an alias to ls -l). Another option I use quite often is ls -ad (list all the subdirectories in my current directory, but don't list their contents).
cd directory
Change directory. Using "cd" without the directory name will take you to your home directory. "cd - " will take you to your previous directory and is a convenient way to toggle between two directories. "cd .." will take me one directory up (very useful).
./program_name
Run an executable in the current directory. The ./ is needed when the executable is not on my PATH. An executable which is on my PATH is simply run using: program_name
shutdown -h now
(as root) Shut down the system to a halt. Mostly used for a remote shutdown. Use for a shutdown at the console (which can be done by any user).
halt
reboot
init 6
(as root, three commands) Halt or reboot the machine. Used for remote shutdown, simpler to type than the previous command. Also great if the computer "hangs" (I lose control over the keyboard)--I telnet to it from another machine on the network and remotely reboot it. I use for normal shutdown at the console of a local computer.
vlock
(Not present on older versions of RedHat.) Lock a local (text mode) terminal. I can also use vlock -a to lock all terminals (probably not a good idea). The best is probably to log out. You don't use vlock in GUI--the windows managers come with password-protected screensaver and a locking utility (the small icon with padlock in KDE, the keyboard shortcut ).

csource destination 
Copy files. E.g., cp /home/stan/existing_file_name . will copy a file to my current working directory. Use the "-R" option (stands for "recursive") to copy the contents of whole directory trees, e.g. , cp -R my_existing_dir/ ~ will copy a subdirectory under my current working directory to my home directory.
mcopy source destination
Copy a file from/to a DOS filesystem (no mounting of the DOS filesystem is necessary). E.g., mcopy a:\autoexec.bat ~/junk. See man mtools for other commands that can access DOS files without mounting: mdirmcd,mrenmmovemdelmmdmrdmformat .... We don't use the mtool commands that often--operations on DOS/MS Windows files can be performed using regular Linux commands after you mount the DOS/MS Windows filesystem.
mv source destination
Move or rename files. The same command is used for moving and renaming files and directories.
rename string replacement_string filename
Flexible utility for changing parts of filenames. For example:
rename .htm .html *.htm
ln source destination
Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it. Any changes to the file are automatically visible throughout. When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: the files have to be on the same filesystem, hard links to directories or special files are impossible.
ln -s source destination
Create a symbolic (soft) link called "destination" to the file called "source". The symbolic link just specifies a path where to look for the "real" file. In contradistinction to hard links, the source and destination do not have to be on the same filesystem. In comparison to hard links, the drawback of symbolic links are: if the original file is removed, the link is "broken"--it points to nowhwere; symbolic links can create circular references (like circular references in spreadsheets or databases, e.g., "a" points to "b" and "b" points back to "a"). In short, symbolic links are a great tool and are very often used (more often than hard links), but they can create an extra level of complexity.
rm files
Remove (delete) files. You must own the file in order to be able to remove it (or be "root"). On many systems, you will be asked for a confirmation of deletion; if you don't want this, use the "-f" (=force) option, e.g., rm -f * will remove all files in my current working directory, no questions asked.
mkdir directory
Make a new directory.
rmdir directory
Remove an empty directory.
rm -r files
(recursive remove) Remove files, directories, and their subdirectories. Careful with this command as root--you can easily remove all files on the system with such a command executed on the top of your directory tree, and there is no undelete in Linux (yet). But if you really wanted to do it (reconsider), here is how (as root):
rm -rf /*
rm -rf files
(recursive force remove). As above, but skip the prompt for confirmation, if one is set on your system. Careful with this command particularly as root--see the command above.
mc
Launch the "Midnight Commander" file manager (looks like "Norton Commander" for Linux). According to some computer dinosaurs, this is the best file manager ever.
konqueror &
(in X terminal) Launch the KDE file manager. Perhaps this is the utltimate for file managment. Much better that the MS "Windows Explorer". It embeds web browsing, pdf viewing, and more. Really cool.
xwc
(in X terminal). Another excellent file manager (called "X Win Commander"). Faster than konqueror, but not as loaded with features.
nautilus &
(in X terminal). A really cool file manager. Slower than konqueror, but offers me goodies like icon-preview of the content of files (!). It even "previews" the contents of sound files! Speedwise, it runs great on my 1.33 GHz computer, but I don't use it on my 133MHz computer.

cat filename | more
View the content of a text file called "filename", one page a time. The "|" is the "pipe" symbol (on many American keyboards it shares the key with "\").more makes the output stop after each screenful. For long files, it is sometimes convenient to use the commands head and tail that display just the beginning and the end of the file, or less that enables scrolling up and down. If you happened to use cat a binary file and your terminal displays funny characters afterwards, you can restore it with the command reset.
cat filename | less
less filename
(two commands, use either) Scroll a content of a text file. Press q when done. "less" is roughly an equivalent to "more" , the command you know from DOS, but often "less" is more convenient than "more" because it lets me scroll both up and down.
head filename
Print first 10 lines of the (long) text file.
tail filename
Print last 10 lines of a long or growing text file. Use tail -f filename for tail to follow the file as it grows--really handy for continuing inspection of log files.
pico filename
Edit a text file using the simple and standard text editor called pico. Use x to exit. There are many text editors for Linux, including several GUI-based. A brand new clone of pico (GPLed) is nano.
pico -w filename
Edit a text file, while disabling the long line wrap. Handy for editing configuration files, e.g. /etc/fstab.
kwrite
(in X terminal) Very nice, "advanced text editor". Supports veritical text selection!
kate
kedit
gedit
(in X terminal). Simple yet nice text editors (GUI based).
gxedit
(in X terminal) Another multi-purpose, feature packed text editor. This one even has timed backup.
latte
(in X terminal) "Code" editor, i.e., plain text editor meant for writing programs.
nedit
(in X terminal) Another programmer editor. Very nice and loaded.
bluefish
(in X terminal) html editor (source with syntax highlighting and maaaany tools and options).
ispell filename
Spell check an ASCII text file. AbiWord, WordPerfect, StarOffice and other word processors come with "as-you-type" spellchecking, so you really don't have to worry about the simple ispell unless you need it. Newer Linux distributions (e.g., RH7.0) contain an improved spellchecking module called aspell, yet the above command will still work.
look thermo
Look up the dictionary on your system (/usr/share/dict/words) for words which start with "thermo".
wvHtml ms_word_document.doc > filename.html
Convert a MS Word document to the html file format.

find / -name "filename" 
Find the file called "filename" on your filesystem starting the search from the root directory "/". The "filename" may contain wildcards (*,?).
The find command is very powerful. It has many options that will let you search for files in a variety of ways e.g., by date, size, permissions, owner, .... Yet some search queries can take you more than a minute to compose. Seeinfo find. Here are some more complex examples for using find to accomplish some useful tasks.
find $HOME -name core -exec rm -f {} \;
The above command finds files named "core", starting from your home directory. For each such file found, it perform the action "rm -f" (force-deleting the file). The {} stands for the file found, and the "\" terminates the command list.
find /dev -user "peter" |more
The above command prints the filename for all devices owned by user "peter". Printing the filename is the default "action" of find, so it does not have to be specified if this is all I need.
find /home/peter -nouser -exec ls -l {} \; -ok chown peter.peter {} \;
Find files without a valid owner in the /home/peter directory. List the file in a long format. Then prompt to change the ownership to the user "peter" and the group "peter". You probably need to be root to hand over the ownership of a file.
locate filename
Find the file name which contains the string "filename". Easier and faster than the previous command but depends on a database that normally rebuilds at night, so you cannot find a file that was just saved to the filesystem. To force the immediate update of the database, I may do (as root): updatedb&.
which executable_name
Show me the full path to the executable that would run if I just typed its name on the command line. For example, this commmand:
which mozilla
on my system produces:
/usr/bin/mozilla
whereis command
Print the locations for the binary, source, and manual page files of the command "command".
rgrep -r 'celeste' . |more
grep -r 'celeste' . |more
(Two commands, use the one that works on your system.) Search all files in the current directory and all its subdirectories (the option "-r" stands for "recursive") for the example string "celeste". Print the filename and the line in the file that contains the searched string.
kfind &
(in X terminal). A GUI front-end to find and grep. Very nice. The & at the end of the command makes kfind run in the background so that the X terminal remains available.

No comments:

Post a Comment