| Homepage | Content | Slides | Video |
Warning
This lesson is under construction. Learn from it at your own risk. If you have any feedback, please fill out our General Feedback Survey.
A shell is a text-based user-interface for a computer.
$ pwd # Prints the current working directory (where you are)
$ ls # Prints the contents of the current working directory
$ cd <path/to/other/directory> # Navigates to a new directory.
$ echo "some thing $AND_VARS" # Prints a string to the screen.
$ cat foo.txt bax.txt # Prints the contents of a file(s) to the screen.
$ grep foo file.txt # Searches `file.txt` for the string `foo`
$ less file.txt # Prints a file to the screen so you can arrow up/down.
$ env # Prints environment variables to the screen.
$ whoami # Prints out current user
$ help # When in doubt, always type help.
about_me.sh
#!/bin/sh
if [ $(whoami) == "root" ]; then
echo "You're root!"
else
echo "Your username is $(whoami)"
echo "Your home-directory is $HOME"
echo "Your current directory is $PWD"
echo "Your computer's host-name is $HOSTNAME"
fi
Invoke with:
$ chmod +x about_me.sh # Tell Linux that this can be run as a program.
$ ./about_me.sh # Invoke the script.
Separates directories: one_dir/another_dir/last_dir
Alone, or at the start of a path, it is the root directory.
$ tree -F
.
|-- bar/
| |-- one
| `-- two
|-- baz/
`-- foo/
`-- a/
`-- b/
5 directories, 2 files
Used as a stand-in for any character(s).
Example: cat *.log cats all files in the current working directory ending in .log.
Used to specify a set.
Example: ls {foo,bar,baz}ley-thing expands to ls fooley-thing barley-thing bazley-thing
Escape special characters (treat them as normal characters) with the escape character (\).
Pressing the tab key auto-completes a command, file-path, or argument in your shell.
Pressing tab multiple times completes the command to the best of the shells ability and then lists the possible completions (if there are any).
$ ls b # <tab>
$ ls ba # <tab>
bar_thing/ baz_thing/
$ ls bar # <tab>
$ ls bar_thing
Lesson 4: Users, Groups, Permissions
Enter search terms or a module, class or function name.