Built-in Shell Commands:
What are they?
They are part of a shell. In other words, each shell (e.g., C Shell, Bourne Shell and Korn Shell) has a set of commands built into its program.
Otvaranje Shella
Control + Alt + F1
Where F1 can be replaced by F2, F3, and so on. The graphical desktop tends to run in F7 or F8, so to go back to your graphical desktop screen, just hit Control + Alt + F7
| ls |
list files in the current directory. |
| cd |
working directory. If your current path is /home/username/Trash for instance, typing "cd" will bring you back to /home/username. |
| mkdir |
a new directory |
| rmdir |
a directory (must be empty) |
| cp |
such as "cp currentFile newFile", and is used to copy files. |
| mv |
such as "mv currentLocation newLocation". This is used to either move or rename files. |
| rm |
such as "rm myFile"; it is used to delete files permanently. |
| pwd |
the working (current) directory. |
| cat |
files (can be used to join them together), and prints its output to standard output (the terminal screen) |
| locate |
entries from a database, that is updated regularly; invoked via "locate myFile". Its much quicker than find (since it only searches a database), but might not be as quick to update as find (the update of the database might happen once every day only). |
| date |
the current date! This can also be used to set the date of the system (but administrator privileges are required). |
| history |
in shell command for the BASH environment that shows the last run commands. |
Input/Output Redirection and Pipes (> >> |)
Man Pages
Exercises
1. Open up a shell on your Desktop and perform the following:
- find the name of the directory you are in
- list out the contents of the current directory
- list out the contents of the directory /usr/bin
- check the current date and time
2. Change directory to your home directory and make a new sub-directory there named Temp11 and change directory to it
- copy the following files from the /etc directory to the directory Temp11: services, motd, fstab, hosts
- concatenate the files copied above into one single file called file1
- count the number of lines present in the file file1
- delete the four files listed above in the directory Temp11
često korištene naredbe
| login |
Prijava na sustav |
| logout |
Odjava sa sustava |
| cd |
Promijeni direktorij |
| alias |
Prikaži aliase |
| history |
Prikaži popis korištenih naredbi |
| kill |
Šalje sinal nekom procesu. Uobičajeni signal je term (terminate) koji zaustavlja proces |
rijeđe korištene naredbe
| bg |
Resumes job in the background. |
| fg |
Brings a job in the foreground. |
| stop |
Stops a background job. |
| echo |
Writes arguments to the standard output of the shell. |
| nohup |
Ignores the hangup signal. |
| set |
Displays or set the value of a shell variable. |
| setenv |
Sets environment variables. |
| unset |
Deletes shell variables. |
| unsetenv |
Deletes environment variables. |
još rijeđe korištene naredbe
| # |
Marks a command. |
| break |
Resumes execution after the loop. |
| breaksw |
Breaks from a switch command; resumes after the endsw command. |
| case |
Defines a label in a switch command. |
| continue |
Continues a loop. |
| default |
Specifies the default case in a switch. |
| dirs |
Displays the directory stack. |
| eval |
Evaluates a command. |
| exec |
Executes the command in the current shell. |
| exit |
Exits the shell. |
| foreach |
Specifies a looping control statement and execute a sequence of commands until reaching an end command. |
| glob |
Writes arguments to the standard output of the shell, like the echo command, but without the new line. |
| goto |
Continues execution after the specified label. |
| hashstat |
Displays hash table statistics. |
| if |
Executes a command if condition met. |
| jobs |
Lists active jobs. |
| limit |
Sets or list system resource limits. |
| nice |
Changes the priority of commands run in the shell. |
| notify |
Notifies the user about changes in job status. |
| onintr |
Tells the shell what to do on interrupt. |
| popd |
Pops the top directory off the directory stack and changes to the new top directory. |
| pushd |
Exchanges the top two elements of the directory stack. |
| rehash |
Re-computes the hash table of the contents of the directories in the path shell variable. |
| repeat |
Repeats the execution of a command. |
| shift |
Shifts shell arguments. |
| source |
Reads commands from a script. |
| suspend |
Stops the current shell. |
| switch |
Starts a switch. |
| umask |
Shows or set file permissions. |
| unalias |
Removes command alias. |
| unhash |
Disables the internal hash table. |
| unlimit |
Removes limitations on system Resource. |
| wait |
Waits for background jobs to complete. |
| while …end |
Executes the commands between the while and matching end statements repeatedly. |
| @ |
Displays or set the values of all the shell variables. |
Unix Commands
# Are these also part of the shells?
No. Each Linux / Unix command is a separate executable program. They are written in C, or less likely, in other programming languages.
System Calls:
chdir
chmod
chown
chroot - change root directory
exit
kill
mkdir - create a directory
mount
reboot - reboot or enable/disable Ctrl-Alt-Del
rename - change the name or location of a file
rmdir - delete a directory
umount