Skip to content

Commit

Permalink
Merge pull request NisreenFarhoud#14 from dontrebootme/master
Browse files Browse the repository at this point in the history
Added others to chmod example, line ending cleanup
  • Loading branch information
NisreenFarhoud committed Mar 21, 2015
2 parents 34e72f9 + 2b14a0d commit 89e040e
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Bash Shell Cheatsheet
=====================
The main topics of this cheatsheet include an intro to the shell, navigating around the shell, common commands, environment variables, connectors, piping, I/O redirection, permissions, and keyboard shortcuts.
##Introduction to the Shell
The shell is a program, in our case, called "bash" which stands for Bourne Again Shell.
The shell is a program, in our case, called "bash" which stands for Bourne Again Shell.
How the shell works is it takes your commands and gives them to the operating system to perform.
In order to interact with the shell, we use "terminal emulators" such as the [gnome-terminal](https://help.gnome.org/users/gnome-terminal/stable/), [eterm](http://www.eterm.org/), nxterm, etc.
In order to interact with the shell, we use "terminal emulators" such as the [gnome-terminal](https://help.gnome.org/users/gnome-terminal/stable/), [eterm](http://www.eterm.org/), nxterm, etc.
##Navigating Around The Shell
On a Linux system, files are organized in a hierarchical directory structure.
On a Linux system, files are organized in a hierarchical directory structure.
This means there is a starting directory called the root directory.
This directory contains files and subdirectories that lead into other subdirectories.
###pwd
Expand Down Expand Up @@ -65,7 +65,7 @@ The `less` command gives you a way to navigate through a passed file or block of
$ less test.txt
$ ps aux | less
```
Common less keyboard shortcuts | Description
Common less keyboard shortcuts | Description
--- | ---
`G` | Moves to end of file
`g` | Moves to beginning of file
Expand Down Expand Up @@ -95,7 +95,7 @@ $ echo $?
```
###grep
The `grep` command is a search function. <br>
Passing a string and a file searches the file for the given string and prints the occurrences to standard output.
Passing a string and a file searches the file for the given string and prints the occurrences to standard output.
```
$ cat users.txt
user:student password:123
Expand All @@ -105,7 +105,7 @@ Passing a string and a file searches the file for the given string and prints th
```
`grep` can take multiple files as parameters and regular expressions to specify a pattern in text.

Common flags | Description
Common flags | Description
--- | ---
`-i` | remove case sensitivity
`-r` | search recursively through directories
Expand Down Expand Up @@ -147,9 +147,9 @@ The `ps` command, short for process status, prints out information about the pro
PID TTY TIME CMD
35346 pts/2 00:00:00 bash
```
There are four items displayed:
There are four items displayed:
* process identification number (PID)
* terminal type (TTY),
* terminal type (TTY),
* how long process has been running (TIME)
* name of command that launched the process (CMD)

Expand Down Expand Up @@ -201,7 +201,7 @@ Connector | Description
test.txt file1.txt file2.txt
```
##Piping
Pipes connect multiple commands together by sending the stdout of the first command to the stdin of the next command.
Pipes connect multiple commands together by sending the stdout of the first command to the stdin of the next command.
For example, the following sends the `ls` output to `head` so that only the top 10 items get printed. <br>
```
$ ls -l | head
Expand Down Expand Up @@ -238,7 +238,7 @@ But we can combine I/O redirection into one command line, such as:
Adding a `&` with the `>` symbol results in redirecting both standard out and standard error.
For example, the `test.cpp` file prints the string "stdout" with `cout` and the string "stderr" with `cerr`.
```
$ g++ test.cpp
$ g++ test.cpp
$ ./a.out >& test.txt
$ cat test.txt
stdout
Expand All @@ -248,13 +248,13 @@ The `>` symbol alone only redirects standard output. <br>
If you only want to redirect a specific file descriptor you can attach the file descriptor number to `>`.

Name | File Descriptor | Description
--- | --- | ---
--- | --- | ---
stdin | 0 | standard input stream
stdout | 1 | standard output stream
stderr | 2 | standard error output stream
For example, if I only wanted to redirect "stderr" to the file `test.txt` from the above example, I would do the following:
```
$ g++ test.cpp
$ g++ test.cpp
$ ./a.out 2> test.txt
stdout
$ cat test.txt
Expand All @@ -265,24 +265,25 @@ The command `ls -l` prints out a lot of information about each file that is info
```
$ ls -l test.txt
-rw-rw-r-- 1 user group 1097374 January 26 2:48 test.txt
```
```

Output from example above | Description/Possible Outputs
--- | ---
- | File type: <br> `-`= regular file <br> `d`= directory
Output from example above | Description/Possible Outputs
--- | ---
- | File type: <br> `-`= regular file <br> `d`= directory
rw- | Permissions for owner of file
rw- | Permissions for members of the group owning the file
r-- | Permissions for all other users
user | name of user owning the file
group | name of group owning the file
###chmod
The `chmod` command, short for change mode, changes the permissions of a file. <br>
There is a combination of letters that need to be known in order to change specific users' permission.
There is a combination of letters that need to be known in order to change specific users' permission.

Letter | User
--- | ---
u | User who owns it
g | Users in the group
o | Other users not in the group
a | All users
You call `chmod` by describing which actions you want to perform and to which file.
The `-` symbol represents taking away permissions while the `+` symbol represents adding permissions.
Expand Down Expand Up @@ -312,7 +313,7 @@ CTRL-A | Move cursor to beginning of line
CTRL-E | Move cursor to end of line
CTRL-R | Search bash history
CTRL-W | Cut the last word
CTRL-U | Cut everything before the cursor
CTRL-U | Cut everything before the cursor
CTRL-K | Cut everything after the cursor
CTRL-Y | Paste the last thing to be cut
CTRL-_ | Undo
Expand Down

0 comments on commit 89e040e

Please sign in to comment.