|
|
Previous Page : The first commands to experiment Using The Shell IIISummary:
Unix (and its younger brother Linux) have been born on the command line. Because of this, the command line in Unix features a lot of mechanism to spare you some menial typing. This page introduces some of them. Auto-CompletionWhat is the shortest way to switch your current working directory from your home directory to the directory '/usr/src/linux/Documentation/isdn/' using the 'cd' ('change directory') command? It's cd /u<TAB>sr<TAB>l<TAB>/D<TAB>is<TAB> This is called 'automatic command line completion' and it is indispensable. Let's have a closer look at the example: cd /u<TAB> expands to cd /usr/. Easy. Next cd /u<TAB>sr<TAB> expands to cd /usr/src/. If you just enter cd /u<TAB>s<TAB>, you will be presented with a choice of three subdirectories of '/usr' which all match this pattern ('cd /u*/s*'): '/usr/sbin', '/usr/share' and '/usr/src'. So the <TAB> key is a handy means to search directories for files or subdirectories you know the first letters of. For example ls /usr/bin/zip<TAB> gives you a list of all files and subdirectories in '/usr/bin' that start with the letters 'zip'. Of course there are much more powerful commands for this tasks, but it does the trick when you're in a hurry. cd /u<TAB>sr<TAB>l<TAB> expands to cd /usr/src/linux and waits for a decision. There are two directories in '/usr/src' that match: '/usr/src/linux-{...}' and '/usr/src/linux'. How do you tell the shell you want the latter? Append a slash ('/'), thus indicating the end of this last name. cd /u<TAB>sr<TAB>l<TAB>/d<TAB> expands to '/usr/src/linux/drivers/'. Looks like it was 'Documentation' (with a capital 'D') then. This kind of completion works for commands, too: {tom@belbo tom}$ gre Here the shell presents me with a list of all the commands it knows about which start with the string 'gre'. Commandline HistoryUsing the up-arrow key you can scroll through all the shell commands you have issued on that console recently. Using the down-arrow key you can scroll back again. Together with the SHIFT key, you can scroll through previous output on the console. You can also edit 'old' command lines and issue them again. Pressing <CTRL r> puts the shell into "reverse-i(ncremental)-search" mode. Now type the first letter of the command you are looking for: (reverse-i-search)`':. Typing 'i' may change this line to: (reverse-i-search)`i': isdnctrl hangup ippp0 If you now press the <ENTER> key, this command will be executed again. If you press the left or right cursor key or <ESC> instead, you will have this command on a normal command line where you can edit it. Commandline EditingYou can navigate and edit the command line with the cursor and the function keys ('Home', 'End' etc), if you like, but there are also keyboard shortcuts for most standard editing tasks:
Available Shell ShortcutsMandriva Linux comes with a row of shortcuts, some are native features of bash, some are pre-configured (you'll learn later on how to configure your own shortcuts). Since the home directory is the focus point of activity for every user, many Unix systems provide special shortcuts for it. Mandriva Linux provides you with a set of pre-configured shortcuts (called 'aliases'):
Next Item: Queuing, jobbing and substituting commands Related Resources:~MdkRef, 3.5 Revision / Modified: Feb. 28, 2002 Legal: This page is covered by the GNU Free Documentation License . Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft. |