tutorials:2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:2 [2022/09/26 23:12] – ↷ Links adapted because of a move operation tcmal | tutorials:2 [2023/07/29 11:18] (current) – removed tcmal | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
- | ======= Tutorial 2: Basic navigation of the command line environment ======= | ||
- | |||
- | |||
- | When you log in via SSH, you are presented with the command line interface, by means of the shell. The current default is Bash. Bash stands for " | ||
- | |||
- | |||
- | ===== Prevent your home directory from being globally accessible ===== | ||
- | |||
- | |||
- | Since Linux is a Unix-like system, it inherits many features from Unix's design. On multi-user systems, this includes having everyone' | ||
- | This may not be desirable to you, especially if you use your shell account for idling on IRC all day, and have a few private messages you might not want everyone to be able to see (however, note, do not have an expectation of privacy on insecure, multi-user systems). | ||
- | |||
- | In the shell, type **chmod -R o-rwx ~** | ||
- | |||
- | The tilde ' | ||
- | |||
- | |||
- | ===== Running programs ===== | ||
- | |||
- | |||
- | To run a program, you need to know the name of that program. All you need to do is type that name, or if it is a specific script or program in a non-standard place, you will need to type the path of it as well (more on this later). A lot of the non-interactive Linux programs take command-line options which are additional words or filenames you type after the name of the program. For example, the Linux program **cat** (short for " | ||
- | **< | ||
- | This simply dumps the content of the file " | ||
- | Try typing **ls /** | ||
- | Now try typing **ls / -l** | ||
- | This simply lists the files and directories in the root of the filesystem (referred to simply as "/" | ||
- | It is worth mentioning that the Linux command-line is case sensitive, unlike windows - this means that **cat** is different from **CAT** and from **Cat** etc. - only one will work, because there is no program called " | ||
- | |||
- | |||
- | ===== Learning how to use programs ===== | ||
- | |||
- | |||
- | The best way to learn how a program works and how to use it is by reading the man page (manual page) built into the system about that program. To find out what a program does and how to use it, simply type man [program name]. Try it now - type: | ||
- | **< | ||
- | You can scroll up and down using up and down arrows, page up and page down, and space and return. Don't worry if you don't understand everything written there, you're not expected to memorize all of a program' | ||
- | |||
- | I should also mention the other manual command, info which (most of the time) shows the same info as man, but uses Emacs to display it. However, certain programs (such as tar) have much more useful information in the info page than the man page, because certain GNU programmers are very awkward about these things. You don't really need to worry about this though. | ||
- | |||
- | |||
- | ===== Finding a program for your purpose ===== | ||
- | |||
- | |||
- | If you know what sort of program you want to run, but aren't sure of the name (or if such a program exists), you can use **apropos** to search for a program by function. For instance, say we want to find an IRC client but we don't know the names of any. We type: | ||
- | **< | ||
- | But we get quite a lot of matches, most of which are no use to us. This is because the search has turned up a load of results where " | ||
- | **< | ||
- | Yay, we've narrowed our matches down to what we wanted! Alternatively we could have tried **apropos "irc client" | ||
- | |||
- | |||
- | ===== Navigating the filesystem ===== | ||
- | |||
- | |||
- | Just like in windows, you can use **cd** to change directory. Why don't we use it in combination with ls to have a browse around the filesystem right now! To change to a directory, simply type **cd** and that directory' | ||
- | To go up a step in the directory tree type cd .. | ||
- | Notice you are now in the /home/ directory with all the users' home directories. To return to your specific home directory, type **cd [your username]** | ||
- | To go to the root of the filesystem type **cd /** | ||
- | You can also use tab completion - this is where you press tab partway through typing the name of the directory (or filename) and the shell completes it for you (if there is only one possible match). Otherwise you will hear a beep. If you press tab a second time, it will list all the possible completions for what you've typed already. Type **cd ~** to return to your home directory. | ||
- | You can navigate faster by using absolute paths. The current directory can be printed to the shell by typing **pwd** - this is useful to remember for scripts that you write for the shell. If you wanted to look at the source of my web page, you could type: | ||
- | |||
- | **< | ||
- | cd .. | ||
- | cd .. | ||
- | cd var | ||
- | cd autofs | ||
- | cd www | ||
- | cd users | ||
- | cd rain | ||
- | cd pages | ||
- | </ | ||
- | But it is infinitely more efficient to type **cd / | ||
- | |||
- | All this takes a little getting used to, and it's useful to have a command reference nearby - I recommend printing this handy [[tutorials: | ||
- | |||
- | |||
- | ===== Changing your shell ===== | ||
- | |||
- | |||
- | If you decide you want to try another shell, you can type the name of it, e.g. **zsh** (Z Shell) to start it. However, to change it so that it is your login shell, the traditional **chsh** will not work. This is due to LDAP (the way that Tardis manages accounts). Please ask on our IRC channel if you want to change it. | ||
- | |||
- | **Next: [[tutorials: | ||