Freedom The Open Source Way Contribute Articles or News to OSForgeOSForge HomeLogout from Forums
Contacting OSForgeOSForge HomeAbout OSForge
  

Root
Contribute News
Learning Corner
Linux Distributions
Linux Common FAQ's
Discussion Forums
Community Gallery
Links Directory
Search OSForge
Networking
Industry Updates
Linux & Open Source
Opinions
Press Release
Programming
Security
Web Development

White Paper
OpenKM - Document Mangement announces version 2.0
SugarCRM Manages End-to-End SaaS Offering with Zenoss
Linux Foundation’s Annual Collaboration Summit Kicks Off
Engine Yard Kicks Off Hackfest Series for Ruby Developers
Plat'Home Launches First Linux-based Eco-Friendly Servers In United States
World’s Largest Python Conference Sees 70 Percent Jump in Attendance
Leading SaaS Infrastructure Provider Deploys Zenoss to Improve Uptime and Reduce Cost
JasperSoft is Most Widely-Deployed Business Intelligence Software in the World
Cluster Resources to Showcase Adaptive Windows/Linux Cluster at BrainShare
Funambol Helps New AGPLv3 Open Source License Gain Formal OSI Approval

View More »

Linux Newbie Guide IX - Linux Commands

Page: 1/6  [Printable Version]



Linux Shortcuts and Commands

Intro. This is a practical selection of the commands we use most often, find useful, and which came on our Linux distribution CDs (RedHat or Mandrake). Press <Tab> on the empty command line to see the listing of all available commands (on your PATH). On my small home system, it says there are 3786 executables on my PATH.  Many of these "commands" can be accessed from your favourite GUI front-end (probably KDE or Gnome) by clicking on the right menu or button. They can all be run from the command line (unless you didn't install the package, but they all came on our CDs).  Programs that require GUI have to be run from under the GUI, for example from a terminal opened in kde or gnome (e.g., xterm). Some more advanced (less useful for a newbie?) tools are described in the Part Learning with Linux of this Guide.

Notes for the UNIX Clueless:
1. LINUX IS CASE-SENSITIVE. For example: Netscape, NETSCAPE and nEtscape would be three different commands (but of the three, only netscape is avialable on my system). Also my_filE, my_file, and my_FILE are three different files. Your user login name and password are also case sensitive. (This goes with the tradition of UNIX and the "c" programming language being case sensitive.)
2. Filenames can be up to 256 characters long and can contain letters, numbers, "." (dot), "_" (underscore), "-" (dash), plus some other non-recommended characters.
3. Files with names starting with "." are normally not shown by the ls (list) or dir command. Think of these "dot" files as "hidden". Use ls -a  (list with the option "all") to see these files.
4. "/" is an equivalent to DOS "" (root directory, meaning the parent of all other directories, or a separator between a directory name and a subdirectory or filename). For example, try cd /usr/doc
5. Under Linux, all directories appear under a single directory tree (there are no DOS-style drive letters).  This means directories and files from all physical devices are merged into this single file system.
6. In a configuration file, a line starting with # is a comment.  When changing a configuration file, don't delete old settings--comment out the original lines. Always insert a short comment describing what you have done.
7. Linux is inherently multi-user. Your personal settings are in your home directory which is /home/your_user_login_name. Many settings are kept in files with names starting with a dot "."so as to keep them out of your way (see point 3 above).
8. System-wide settings are kept in the directory /etc .
9. Under Linux, as in any multiuser operating system, directories and files have an owner and set of permissions. You will be typically allowed to write only to your home directory which is /home/your_user_login_name. Learn to use the file permissions else you will be constantly annoyed with Linux.
10. Command options are introduced by a dash, "-", followed by a single letter (or -- when the option is more than one letter). Thus "-" is an equivalent of DOS's switch "/". For example, try rm --help.
11. Type command& (the command name followed by an  &) to start a command in the background. This is usually the preferred way of starting a program from the X-window terminal.

Linux essential keyboard shortcuts and sanity commands

<Ctrl><Alt><F1>
Switch to the first text terminal. 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").

tty
Print the name of the terminal in which you are typing this command.  The number of the active terminal can be printed using the command fgconsole.

<Ctrl><Alt><F7>
Switch to the first GUI terminal (if X-windows is running on this terminal).

 <Ctrl><Alt><Fn> (n=7..12)
Switch to the nth GUI terminal (if a GUI terminal is running on screen n-1). On default, nothing is running on terminals # 8 to 12, but you can run another server there.

 <Tab>
(In a text terminal) Autocomplete the command  if there is only one option, or else show all the available options. THIS SHORTCUT IS GREAT! It even works at LILO prompt!

 <ArrowUp>
(In a text terminal) Scroll and edit the command history. Press <Enter> to execute.

 <Shift><PgUp>
Scroll terminal output up. Work also at the login prompt, so you can scroll through your bootup messages.

 <Shift><PgDown>
Scroll 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>
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 a 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.

<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, the second shell will be exited and you will be back in the first shell, not logged out.)

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.

<MiddleMouseButton>
Paste the text which is currently highlighted somewhere else. This is the normal "copy-paste" operation in Linux.  (It doesn't work with Netscape and WordPerfect which use the MS Windows-style "copy-paste". It does work in the text terminal if you enabled "gpm" service using "setup".) Best used with a Linux-ready 3-button mouse (Logitech or similar) or else set "3-mouse button emulation").

~
(tilde) 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 ~".

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

<Alt><SysRq><command_key>
(Non-essential.) This is a group of key combinations is implemented at the Linux kernel level (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; 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.
<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.

   Next Page >> (2/6) Next Page >>

[ Back to Linux Computing | Sections Index ]

 
Scroll Up

   About | Term of Use | Privacy | Adras | Tell a Friend | Advertise  

OSForge News RSS Feed