FreeBSD
This is a FreeBSD info site in Slovakia, Bratislava.
THE UNIX COMMANDS
ls -This command lists the files and subdirectories in a directory. If you simply type "ls", it will display the files in your current directory. You can also specify the pathname of another directory, and it will display the files in it. It will not display hidden files (files whose name begins with a period). Options: a -This option will display all files, including hidden files. Example: ls -a . .. junk source cd -This is the command used to move from one directory to another.
cd -To go to a directory directly below your current directory,
type "cd
cat -You can use basenames or pathnames. Example: $cat memo Bill, Remember to feed the cat! -Martha
rm -This deletes a file. Syntax: "rm
cp -Copies a file. Syntax: "cp file1 file2", where file1 is the file you wish to copy, and file2 is the name of the copy you wish to create. If file2 already exists, it will be overwritten. You may specify pathnames for one or both arguments. Example: cp /usr/junk /usr/junk.backup stty -Displays/sets your terminal characteristics.
stty - To display the current settings, type "stty". To change a setting, specify one of the options listed below. Options: echo -System echoes back your input. noecho -System doesn't echo your input. intr 'arg' -Sets the break character. The format is '^c' for control-c, etc. '' means no break character. erase 'arg' -Sets the backspace character. Format is '^h' for control-h, etc. '' means no backspace character.
kill (+arg) -Sets the kill character (which means to ignore the last line you typed). Format is the same as for intr and erase, '^[character]', with '' meaning no kill character. Example: $stty intr '^c' erase '^h' $stty stty -echo intr '^c' erase '^h' kill '^x' lpr -This command prints out a file on the Unix system's printer, for you to drop by and pick up (if you dare!) The format is "lpr":
The file you wish to modify is not modified directly by the editor; it is loaded into a buffer instead, and the changes are only made when you issue a write command. If the file you are editing does not already exist, it will be created as soon as issue the first write command.
When you first issue the edit command, you will be placed at the command prompt, ":" Here is where you issue the various commands. Here is list of some of the basic editor commands. # -This is any number, such as 1, 2, etc. This will move you down to that line of the file and display it. d -This deletes the line you are currently at. You will then be moved to the previous line, which will be displayed. a -Begin adding lines to the file, just after the line that you are currently on. This command will put you in the text input mode. Simply type in the text you wish to add.
To return to the command mode, type return to get to an empty line, and press the break key (which is whatever character you have set as your break key). It is important to set the break character with stty before you use the editor! / -Searches for a pattern in the file. For example, "/junk" would search the file from your current line down for the first line which contains the string "junk", and will move you to that line if it finds one. i -Insert. Works similar to a, except that the text is inserted before the line you are currently on. p -Prints out a line or lines in the buffer. "p" by itself will display your current line. "#p" will display the line "#".
You may also specify a range of lines, such as "1,3p" which will display lines 1-3. "1,$p" will print out the entire file. w -Write the changes in the buffer to the file. q -Quit the editor. Example: $edit myfile Editing "myfile" [new file] 0 lines, 0 characters :a I am adding stupid text to myfile. This is a test. ^c [this is assumed as a default break character in this example] :1,$p I am adding stupid text to myfile. This is a test. :2 This is a test. :d I am adding stupid text to myfile. :w :q $ grep -this command searches for strings of text in text files. The format is grep [string] [file]. It will print out every line in the file that contains the string you specified. Options: v -Invert. This will print out every line that DOESN'T contain the string you specified. Example: $ grep you letter your momma! I think you're going to get caught. $ who -This will show the users currently logged onto the system. Example: $ who root console Mar 10 01:00 uucp contty Mar 30 13:00 bill tty03 Mar 30 12:15 $ Now, to explain the above output: the first field is the username of the account. The second field shows which terminal the account is on. Console is, always, the system console itself.
On many systems where there is only one dialup line, the terminal for that line is usually called contty. the tty## terminals can usually be either dialups or local terminals. The last fields show the date and time that the user logged on. In the example above, let's assume that the current time and date is March 30, and the time is 1:00. Notice that the time is in 24 hour format. Now, notice that the root (superuser) account logged in on March 10! Some systems leave the root account logged in all the time on the console. So, if this is done on a system you are using, how can you tell if the system operator is really online or not? Use the ps command, explained next. ps -This command displays information about system processes. Options: u -this displays information on a specific user's processes. For instance, to display the root account's processes: $ ps -uroot PID TTY TIME CMD 1234 console 01:00 sh 1675 ? 00:00 cron 1687 console 13:00 who 1780 tty09 12:03 sh Now, to explain that: The first field is the process number.
Each and every time you start a process, running a program, issueing a command, etc., that process is assigned a unique number. The second is which terminal the process is being run on. The third field is when the process was started. The last field is the base name of the program or command being run. A user's lowest process number is his login (shell) process. Note that the lowerst process in the above example is 1234. This process is being run on the console tty, which means the superuser is logged on at the system console. Note the ? as the tty in the next entry, for the cron process. You can ignore any processes with a question mark as the terminal. These processes are not bewing carried out by a user; they are being carried out by the system under that user's id. Next, note the entry for process # 1687, on the console terminal, "who". this means that the superuser is executing the who command...which means he is currently actively on-line. The next entry is interest- ing...it shows that the root user has a shell process on the terminal tty09! This means that someone else is logged in under the root account, on tty09.
mkdir -This command creates a directory. the format is "mkdir
mail to: Juraj