20061010
From Wsms
previous next
Go To:Linux Class Notes
Contents |
[edit]
Some tips about the terminal
To clear screen: <ctrl>+l
[edit]
The history file
There is a history built in in the bash shell. So, every command is saved and user can use it again with the arrow keys.
In each session, the commands are copied into a history file.
Commands that have been done in previous sessions are remembered by this files.
There is a control file that can set the limit of entries in that history file. (it is set by default to 1000 commands.
The bad news about a history file is that it can be used to find out things about password and security facts of the system. It is very dangerous.
[edit]
ssh (secure shell)
Supports remote logon. The other computer must be running the ssh daemon.
[edit]
The Manual in Linux
The command is man
The concept of having an integrated manual was unique to Linux 30 years ago.
It repaces a ton of books
All documentation contains as many as 9 possible sections.
Section 1: General things that are useful for all users.
Sections 2 to 4: Things that are for advanced users, such like systems calls, C libraries and drivers.
Section 5: File formats (that could be interesting).
Section 6: Games (Interesting for some persons).
Section 7: Information pages (miscelaneous).
Section 8: System maintenance and operation commands.
Section 9: System Kernel.
[edit]
Some Command lines
[edit]
General commands
[edit]apropos:
Used to search keywords in whort command descriptions. For example, apropos directory will return all of those commands wich deal with directories.
[edit]ls:
When I execute ls, I don't execute the actual command. Instead, an alias is executed. The proof of this is that when I execute the actual file "/bin/ls", I don't see names in colors.
What happened is that when I type ls, I'm actually executing a command that was modifyed by people who built fedora. That modifyed command is called an alias.
If the file name begins with a ".", it will be hidden, and ls will ignore it.[edit]Information provided by ls
If you use the -l modificator, you will find other information about the files in the directory: Column Information that contains 1 If it is an archive (a), a directory (d), etc... 2-10 permissions 11 A number that represents a number of hard links. Is a concept that doesn't exist in windows. 12 owner. When here appears a number, that means that the /etc/passwd file doesn't have an entry for that user id. 13 a number of entries 14 The date when the file was modificated. 15 The name of the file
A dot before the filename :.filename: Means that the file is hidden.
[edit]Arguments of ls
For example, if I want to see all the entries in the /etc/ directory, that starts with s. I use this command line:
ls /etc/s*
The "*" means everything.
If I need any file wich name starts with either s or t I use this command:
ls /etc/[st]*
If I need any file wich name starts with a letter from a or c I use this command:
ls /etc/[a-c]*
If I need any file wich name only ocupies 3 positions:
ls /etc/???
The proccess that Linux does is first to proccess the characters that are just after the name of the command (ls) and the blank space, and deal with the line translating the sentence to something ls can understand, because ls doesn't understand things like that.
The important thing to understand is that with Linux we allways deal with a two step process: one with the O/S and the other the program you are actually calling by typing the command line.
[edit]echo:
This command is very useful. It returns information that is entered and can be used to generate short text files
The echo program is designed to send the input data to the standard ouput device.
The echo program is useful because there are many examples of configuration files that are one line files, and they can be done with the echo command.
If I create a file with a . before its name, that file is hidden.
[edit]cat:
Concatenate: Take several files and make their contents (that are separated, because they are two or more different files) as one joint content.
[edit]more:
Display a text file to you a page at a time.[edit]less:
Display a text file to you a page at a time (is a newer version of more is the same more plus more, and it is called less because a crazy person named it) Allows to go bacwards through the file you want to see.
When we call the manual comand (man) actually we are using the less comand.[edit]whereis:
Displays the path where a command is.
[edit]
Special characters
'The greater than character >' is used to redirect programs outputs (or redirect the standart output stdout). If we use an unknown name to the system, the system creates a new file and puts the output there.
Normally echo doesn't accept more than one argument (word), so it is recomended to put separated worlds into a quotation mark.
The number sign #: Almost allways means a comment (in almost all cases in configuration files)
The tilde sign ~: Means the home directory.
The smaller than character <: Another kind of redirection.
The vertical bar |: It is called the piping character. This is used to redirect the ouptut of a program to the imput of another program. For example, the command apropos x11 | less allows the user to see the results of the apropos command a page at a time, and navegate through it, as it was was a file (actually it's a temporary file). In a command line, there can be as many pipe characters as necesary
The escape character \: Is used at the end of a command line, so the system expets that the command line continues in the following line. This is used to write better comprehensible commands, or be able to write extremely long commands, that ocupies more than one line.
It is also used to tell the O/S to do something that it usually doesn't do with the next character that appears just after the escape character. For example, the command:
will create a file called test file, with a space in midle. Another example: The following command will insert the quotation mark as text, instead of interpreting it as the boundaries of the text:
- echo "hello world" > test\ file
- echo "Joe says \"hello world\""
The enter key (new line character): It is used to tell the system to take care of the line we have typed, because it's a command line.
[edit]
Some important configuration files
Whenever yuu see a file that ends in "rce", the most frequent of the times, it is a configuration file.
[edit]Some files in your home directory
~/.bash_history: Text file used to store your history.
~/.bashrc & ~/.bash_profile: All files that start with "bash" ae related to the shell. They containts informations that are used durin the logon process. For example, how many atempts to login are allowed.
~/public_html: Private space for web pages
Nothing can be hidden from the administrator.
[edit]
Levels of security in Linux
About the nine columns that appears from column 2 to 10 in the ls command
Linux has the ability to protect data for the last 30 years.
Actually, there are three sets of three columns.
The first set reffers to the users of the file
The second set reffers to the group of the owner of the file
The third set reffers to the others people, or everybody else
There are three possible letters and one symbol (-) for each column:
R:Read; W:Write; X:Execute.
In the windows environment, to know if a file is executable, by viewing the extension. In Linux, we mark a file as executable by turning on an "x" in the third column of the first set of columns (the owner's permissions)
In a case of a directory the "x" means of a "search" permission.
Permissions can be changed by the owner, or the administrator.
Most frequently we use a numerical notation: binary numbers converted to decimal. I can specify permissions by just adding those numbers together if the permission exists.
Example: columns rwx r-x r-x means 4+2+1 2+0+1 2+0+1. That is 755
We can use also the chmod comand with +r or +w or +x that sets on all the permissions of that kind; or [u|g|o]+permission that sets on the permission for the particular set of persons.
[edit]
Runlevels in Linux
There are at least 6: 0:halt. 1:single user mode.. etc. They are listed in the /etc/inittab file.
Level 3 is full multiuser mode, without the graphic mode.
Level 5 is the X11 mode or graphic mode.
Level 1 is extremely dangerous because you come to a text-based screen as the administrator and you don't need to know the root user's password. Yo cannot get to the single user mode, if you don't have a phisical keyboard attached to the server
