![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Complete Idiot's Guide to Linux
Making Shell Options the DefaultIf you found any of these options useful, more than likely you will want to make them the default. When you run a shell, there are a number of environment variables that control how your shell behaves. For the bash shell, the default shell in Linux, this default information lives on the /etc/profile file. You can override some of the options by adding entries to the .bashrc file in your home directory. Because this filename starts with a dot, its invisible by default (and called a dot fileand you thought Linux names would be difficult!), but it is there. To make ls work in color by default, add an entry like this to the end of your .bashrc file. (Use KEdit because you dont know how to use a command line editor, yet.) Here are some examples: alias ls=ls --color To make ls use the -F option, add a line like this: alias ls=ls -F To make ls use both the -F and --color options, add a line like this: alias ls=ls -F --color As you can guess, alias associates a name with a command. To make an alias in bash, you use the keyword alias followed the name of the alias followed by an equal (=) sign, followed by the name of the command. If the command is longer than one word (that is, it has arguments), you need to enclose the command and its arguments in apostrophes (). You can use any name for the alias you like. If the name of the alias is the same as some system command, the alias is the command executed. Check out your .bashrc to see what aliases have already been defined for you. Changing Directories: cdNow that you know how to find out where you are and list the files in a directory, it is time to learn how to go somewhere. To do so, you use the cd command. cd stands for change directory. To go somewhere, type the cd command followed by the name of the directory where you want to go: [alberto@digital alberto]$ cd / [alberto@digital /]$ ls amd/ dev/ install@ opt/ tmp/ auto/ etc/ lib/ proc/ usr/ bin/ home/ lost+found/ root/ var/ boot/ initrd/ mnt/ sbin/ vmlinuz This example takes you to the root (/) directory. To return to your home directory, type the cd command without any arguments: [alberto@digital /]$ cd [alberto@digital alberto]$ ls Desktop/ images/ linkToImages@ test.txt Mail/ kde/ nsmail/ test.txt∼ html/ lg/ test.rc todo.txt Relative and Absolute PathsIf you dont provide a leading slash (/) in the path you specify, the path is relative. The shell will append the current working directory to the path you specify, as in the following: [alberto@digital alberto]$ cd images/anotherdir [alberto@digital anotherdir]$ pwd /home/alberto/images/anotherdir If the directory images is located in /home/alberto/images, the first line is equivalent to specifying this: cd /home/alberto/images/anotherdir When specifying a relative path, it is useful to know that the current directory can be specified using a period (.) and the parent directory, the directory containing the current directory, as two periods (..), given a directory structure like this: [alberto@digital alberto]$ ls Desktop/ images/ linkToImages@ test.txt Mail/ kde/ nsmail/ test.txt∼ html/ lg/ test.rc todo.txt [alberto@digital alberto]$ cd images (goes down to images) [alberto@digital images]$ pwd /home/alberto/images [alberto@digital images]$ cd ../kde (up one and down kde) [alberto@digital kde]$ pwd /home/alberto/kde [alberto@digital kde]$ cd .. (up one) [alberto@digital alberto]$ cd ./kde (down kde in the current dir) [alberto@digital kde]$ pwd /home/alberto/kde
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |