Previous Next Table of Contents

2. Console related questions.

2.1 Q: How do I copy files in Linux?

A: Just use the command "cp filename newlocation". If you f.eks want to copy the file Backup.gz from `/` to `/usr` you would use the command below:

"cp /backup.gz /usr/backup.gz"

*Note that Linux uses a forward slash(/) instead of backslash(\).

To force a copy use a -f option (this overwrites the target if it exist), another usefull option is -r (recursive). This copies files with directories to the destination.

2.2 Q: How do I delete files in Linux?

A: Use the command "rm". F.eks, if you want to delete the file '/usr/bin/hello', you would use the command as showed below:

"rm /usr/bin/hello"

2.3 Q: How do I move files in Linux?

A: Just use the command "mv" as you used the "cp" command.

2.4 Q: How do I rename files in Linux?

A: Use the move-command as showed below:

"mv oldfilename newfilename"

2.5 Q: How do I make/remove an directory in Linux?

A: To make an directory, use the following command:

"mkdir directoryname"

If you want to remove an directory, make sure the directory is empty, and use the following command:

"rmdir directoryname"

2.6 Q: Directory listing.

A: Use the command "ls --color" or "dir --color". You should also try the wonderful "dir --lisa" command. To make any of these changes permanent, just enter the command "alias ???='ls --color --lisa'", and replace the ???'s with the command you want to use as you directory-listing command.("dir" might not be a bad choice. ;) You can ofcourse use any parameters supported by the dir/ls command. "--color --lisa" are just what SNw^tKB use. Try "dir --help" for info on different parameters.

2.7 Q: I used the command "dir --color". What does the colors tell me?

A: Colors in a directory structure tells you the filetype of the different files. Colors might be different from system to system because they are changable, but most often, executable files are green, symbolic links are light blue and directories are blue. To change the colors, edit the file "DIR_COLORS" which can be found in the "/etc" directory.

2.8 Q: How can I view a textfile, as with "type filename |more" under MS-DOS?

A: Just use the command "more filename", but that is rather silly, since Linux have an alot bether text-viewer. Try the command "less filename".

2.9 Q: Why can't I change directories as with "cd.." under MS-DOS?

A: Because you are using Linux. Under Linux and Unix's in general, you should include a space between the "cd" and the ".."'s. To jump right to the root, use the command "cd /".

2.10 Q: How do I start programs under Linux?

A: Just type their name as in MS-DOS, Amigados or whatever you used before... If they are in one of the directories that the PATH variable points to, or in the current directory it will start, otherwise you need to specify the full pathname of the program.

If you want to start a program in your current directory and you have a file with the same name in another directory in your path, put an "./" infront of the command-name. :)

Example:

Let's say you have the "cdp" program in "/usr/bin/cdp" which are reffered to in your path. You just compiled the source of a newer version of cdp in "/usr/src/cdp-1.02/", and you have the "cdp" program in both directories.. To run the program in "/usr/src/cdp-1.02/", and not the one in "/usr/bin/", go to /usr/src/cdp-1.02/ and execute "cdp" with the command "./cdp", and it will execute the one in "/usr/src/cdp-1.02/cdp", and not the one in "/usr/bin/cdp".

(This is btw. why source programs needs to run configure with "./configure", to make sure the right program executes.)

2.11 Q: I have started a text-mode program, and cannot find the exit. HELP!

A: Try pressing 'CTRL' + 'Z' simultanously.'CTRL' + 'C' or 'CTRL' + 'D' might also work. Read 1.13.

2.12 Q: How do I login multiple times at once?

A: Try pressing ALT and one of the function keys from F1 to F6. There, you got multiple logins. To go back to another login, just press ALT and the function key that represent the login you want

2.13 Q: How can I swap bewtween multiple tasks?

A: Use the commands "FG" and "BG". While running an text-mode program, press CTRL+Z, and then type "bg 1", and the program continues to run in the background. Then you can run other programs, and do the same with them, exept that you should use increasing numbers(bg 1 for the first program, bg 2 for the second, and so on.). To go back to one of the programs that run in the background, use the command "fg #", where # is the number you used for the aplication with the "bg" command. You can then switch between all the programs easy. :)

2.14 Q: What's a PID?

A: Proces identification. Every program in a unix environment has a process identification. If you run "ps" you see all the processes you are running. If a program locks up, you can kill it by using the command "kill #" where # is the pid of the locked program.

2.15 Q: My program crashed! What now?

A: Most programs which crash, leaves a file named core which is created for debuging. If you are not a developler and you do not know what it is for, simply remove the core file.

2.16 Q: How do I shutdown my computer?

A: Use the command "Shutdown -h now". Type Shutdown without parameters to see other possible combinations. Sometimes "reboot" does the work too :)

2.17 Q: Is there anything similar to the ms-dos "batchfiles" in Linux?

A: Sure! They are called "shell scripts". They are similar to ms-dos batch files, exept that they use the "C" program language instead of the batch file language. If you have installed the "manual pages", type "man bash", and you will get more information on the subject. :)


Previous Next Table of Contents