Bash internal and external commands
From Initq
Contents |
Intro to Bash
Bash is a Unix Shell written for the GNU Project. The acronym for Bourne-again-shell.
Command Line Interface
cli for short is where all the magic happens. First thing you have to realize about Linux is that everything is a file. A file is a file, a directory is a file that contains information about other files, network connections are files. It's all bits and bytes and linux don't care what those bits and bytes form; instead the programs running on linux do care.
Internal and External Commands
There are many commands that are built into the Bash shell. Since there are vast number of external and internal commands you can use a command called type to figure out whether a command is internal or external:
[alibaba@ohnonono ~]$ type cat cat is /bin/cat [alibaba@ohnonono ~]$ type pwd pwd is a shell builtin [alibaba@ohnonono ~]$ ls -la /bin/pwd -rwxr-xr-x 1 root root 22916 Nov 27 2006 /bin/pwd
Keys
you can use the up arrow and down arrow keys to print out the recent commands. You may also use Ctrl-P and Ctrl-N to go up and down the command list.
Move within the line
Now that you have found your command, you may want to edit it. you may use the arrow keys but it's also nice to know that you can use Ctrl-A and Ctrl-E to move all the way to the left or right.
Delete text
Ctrl-D deletes the character under the cursor. Ctrl-K deletes all text from the cursor to the end of the line. Ctrl-X deletes all the text from the cursor to the beginning of the line.
Transpose
Ctrl-T transposes the character under the cursor with the character before the cursor. if you have two words you can transpose then while your cursor is on the second word, hot ESC and then T.
Change Case
Pressing ESC and then L converts the text to lower case and and U converts the text to uppercase. The text that is converted is from your cursor to the end of the line.
Invoke and editor
Ctrl-X and then Ctrl-E. This reads the $FCEDIT or $EDITOR variable. you will need to do
[alibaba@ohnonono ~]$ export EDITOR=vim
pwd is internal and external. here is a list of bash commands.
List
| Name | Category | Description | OS |
|---|---|---|---|
| cat | Filesystem | Concatenate and print files | |
| cd | Change the working directory | ||
| echo | Write arguments to standard output | ||
| env | Misc | Set the environment for command invocation | All |
| exec | Execute commands and open, close, or copy file descriptors | ||
| exit | Shell programming | Cause the shell to exit | All |
| export | Misc | Set the export attribute for variables | Bash Only |
| history | Filesystem | Show history of commands typed | All |
| join | Text Processing | Relational database operator | All |
| logout | Cause the shell to exit | ||
| man | Misc | Display system documentation | All |
| mv | Filesystem | Move or rename files or directory. | |
| od | File Manipulation | Dump files in various formats | All |
| paste | Text processing | Merge corresponding or subsequent lines of files | All |
| pwd | Filesystem | Cause the shell to exit | All |
| rm | Filesystem | Delete files or directories | All |
| set | Set or unset options and positional parameters | ||
| split | File Manipulation | Split files into pieces | |
| sort | Text Processing | Sort, merge, or sequence check text files | |
| tac | File Manipulation | Display file in reverse | All |
| time | Time a simple command | ||
| tr | Text processing | Translate characters | Unix |
| unset | Unset values and attributes of variables and functions | ||
| unexpand | Text Processing | Convert spaces to tabs | Unix |
| uniq | Text Processing | Report or filter out repeated lines in a file | Unix |
