Linux 101
Contents |
Case Sensitive
Linux is a case-sensitive operating system. All files (including directories) and commands require correct capitalization.
The filesystem Structure
The linux filesystem is structured like a tree. The base of the tree is called the root, and is designated by a /. All subsequent directories are branches from the root. Listed below of some of the more important branches:
- /home : Contains the home directories of each user
- /usr : Contains (most) of the programs, libraries, and header files for third party applications
- /sbin & /bin : Constains linux system commands and scripts
- /dev : Contains linux device files. These files allow linux to communicate with devices connected to the computer
- /etc : Contains configuration files and startup scripts
Absolute and Relative Path Names
A path name is a text string containing symbols and characters that represent a specific file or directory. Absolute path names start from the filesystem root and progress to the file or directory. Each directory is separated by a forward slash, /. The following are absolute paths:
- /home/user1
- /usr/local/bin/firefox
Relative paths specify a directory or file starting from the current working directory. Assuming that the current working directory is /home, the following path names are equivalent to the those previously listed:
- user1
- ../usr/local/bin/firefox
The .. symbol refers to the previous directory, which in the example above is the root of the filesystem.
Users and Superuser
Every person who uses a linux computer should have a separate username and password. A standard user has restricted access to parts of the linux filesystem, preventing them from deleting essential files and executing inappropriate commands. There exists one super-user, or root, account from which all functionality is accessible. As a rule of thumb, the super-user account should only be used when absolutely necessary. This prevent accidents from happening.
Each regular user also has a home directory where they can store personal files. The home directory is named after the username of the account. For instance, a person with the username of joesmith will have a home directory of /home/joesmith. The tilde symbol, ~, refers to the current user's home directory, which makes /home/joesmith and ~ equivalent assuming that joesmith is the current user.
The terminal
The basic mode of interacting with linux is via a shell or terminal. The terminal accepts user input through commands, and produces useful output via standard out. The terminal consists of prompt, which typically consists of the current directory path followed by a dollar sign, for example ~ $. When logged in as super-user the prompt changes to a hash #.
Getting around the filesystem
Once a terminal is open, one of the fundamental operations is changing directories and view files. Listed below are a few essential commands:
- ls : The list command will display the contents of the current directory
Example that lists the contents of a fictional home directory
~$ ls public_html/ work/ bin/ ~$
- cd : The change directory command will do what the name implies.
Example that changes directory from the user's home to public_html
~$ cd public_html ~/public_html $
Example that changes the directory back to home in two different manners
~/public_html $ cd ~ ~ $ The cd command without any arguments will also return to the user's home directory ~/public_html $ cd ~$
- less and cat : Used to display the contents of a file. Less allows for scrolling through the file, while cat dumps the entire file contents to the screen
~ $ less my_text_file
- man : Manual command will display help information about a program or script. This is one of the most important commands to remember. If any additional information about a program is needed, including functionality, arguments, return values, then use man.
Example will display the manual page for the ls command.
~ $> man ls
- mkdir : Make a new directory. The last argument is the name of the new directory.
Example to create a directory called "my_dir"
~ $ mkdir my_dir
- rm : Remove a file or directory.
The first example removes a file called "my_file", and the second example removes a directory called "my_dir"
~ $ rm my_file ~ $ rm -rf my_dir
![[LOGO]](/workbook/skins/workbook/create_small2.png)



