fix some wiki typos

This commit is contained in:
Ben Harris 2019-01-25 13:29:10 -05:00
parent e5422b939e
commit af225b4924
2 changed files with 98 additions and 82 deletions

View File

@ -7,7 +7,7 @@ category:
- main
---
# Command Line Shell, for *Absolute* Beginners
# Command Line Shell, for _Absolute_ Beginners
So, you want to join a public-access shell community like tilde.team, but you don't yet have experience using GNU+Linux or other UNIX-like operating systems? This tutorial is designed to give you enough guidance that you can get started and move on to successfully directing your future learning. Once you get a basic level of self-sufficiency, tilde.team is a great place to practice and learn more.
@ -36,6 +36,7 @@ This tutorial will teach you the few commands that should allow you to take care
## What are the first commands a new user should learn?
When you're first starting to use a shell in a UNIX-like environment, you will want to be able to do the following things:
1. logging in and logging out
1. list the files or directories in a directory
1. move between directories
@ -53,26 +54,35 @@ When you're logged into a shell, you should see a command prompt and a blinking
Recall from the How-Do-I-Connect section above that you can use a SSH client to log into tilde.team. Once you're logged in, you can use the command line SSH client to log into any other shell server; in the example below, let's say you want to log into tilde.town from tilde.team.
Skipping some specifics for now, you can log into tilde.town from a tilde.team shell by using SSH as follows:
> `ssh tilde.team`
Some shell servers allow you to log in with nothing more than a username and password. But increasingly, many servers (like both tilde.team and tilde.town) require you to use ssh keys. To learn more about ssh keys, again, see our SSH page: https://tilde.team/wiki/?page=ssh
### Logging Out, with `logout` or `exit`
`logout` is a simple command you can use to log out of a shell. You could also use `exit`.
### Listing Files, with `ls`
To list the files in a directory, simply type `ls`. This will print a list of the files in your current directory.
> `ls`
### Changing Directories, with `cd`
You may move from one directory to another with `cd`. Wherever you are in the file system, you can type `cd` by itself to return to your home directory:
> `cd`
Change to the directory with your html files as follows:
> `cd public_html`
### Read the Contents of a File, with `less`
If you're still in your public_html directory, you should see a file called 'index.php' when you use the `ls` command. Let's peek inside 'index.php' as follows:
> `less index.php`
`less` has opened the 'index.php' file for you to read. You cannot edit it; only read it. Type `q` (quit) to stop viewing the file contents and return to the shell.
@ -96,6 +106,7 @@ Now you can pull up a browser to see the change at your tilde.team URL:
### Create a New File with `nano`
Let's create a new file in your public_html directory, called 'testing.html'.
> `nano testing.html`
'testing.html' did not exist before you opened it with `nano`, so it was created for you.
@ -111,6 +122,7 @@ Later in this tutorial, we will come back to this file and make it viewable in y
First, hop back to your home directory with the `cd` command (remember that `cd` from anywhere in the file system will take you back to your home directory).
Now create a new directory called 'downloads' in your home directory:
> `mkdir downloads`
Use `ls` to see that it was created, and even move into the new directory with `cd downloads`.
@ -122,11 +134,13 @@ First, `cd` back to your home directory, and use `nano` to create two new files
Lets move those into your 'downloads' directory using two different commands, to demonstrate how they workd differently.
Move 'fileone.txt' into 'downloads':
> `mv fileone.txt downloads/`
Now if you `ls` the contents of your home directory, you will no longer see 'fileone.txt', because it has been moved into 'downloads'. If you 'ls' the contents of 'downloads' (a shortcut command is `ls downloads`), you will see it there.
Next, copy 'filetwo.txt' into 'downloads' as follows:
> `cp filetwo.txt downloads`
Now if you `ls` the contents of your home directory, 'filetwo.txt' will still be there. This is because `cp` made a copy of 'filetwo.txt' and put the copy in 'downloads'. It did not touch the original file in your home directory. Verify this with `ls` in your home directory and in 'downloads'.
@ -140,16 +154,19 @@ As long as you're in one of your own directories (e.g. your home, or 'downloads'
Then save it as you have already learned, and confirm that it exists by listing (`ls`) the contents of the directory.
Now, you can delete the file with the `rm` (remove) command:
> `rm testtrash.txt`
Notice that you don't get a warning that you're about to delete it, and you don't even get a confirmation that it is deleted. You've learned your first command that you need to be careful with. If you delete an important file with `rm`, it is gone forever.
You can delete directories the same way, only using the `rmdir` command (remove directory) instead of `rm`. If you use `mkdir testtrash`, you can then delete it as follows:
> `rmdir testtrash`
Note that you can only delete empty directories with `rmdir`.
If you want to delete directories that still have contents in them, use the following:
> `rm -rf directoryName`
Be very, very careful with this command. Many a user, new and seasoned, has been stung by hastily deleting directories like this. This is also the source of the classic sysadmin joke/horror story about `rm -rf /` which deletes the entire file system.
@ -159,6 +176,7 @@ Be very, very careful with this command. Many a user, new and seasoned, has bee
Now `cd` into your 'downloads' directory because we're going to use it for actual downloads.
Use the `wget` (WWW get) command to download a text copy of this tutorial from tilde.team user cmccabe's public_html directory:
> `wget https://tilde.team/~cmccabe/gnu-linux-toot.txt`
You will see output of the command that confirms it is downloading. You can also verify that it has downloaded with your `ls` command. You can also peek at the contents with the `nano` or `less` commands that you learned above.
@ -173,7 +191,7 @@ A brief note on security here, if you do pull any scripts from the Internet usin
At this point, you've learned most of the commands you need for basic self-sufficiency in a GNU+Linux shell environment. With just a few more, you can go a long way. When you want to learn more about a command, you can look at its "man page" with the `man` command. "Man pages" are the instruction manuals for most commands and programs in GNU+Linux.
Try out `man` by looking at any of the commands you've learned already (except `cd`*). For example, `man ls` would open the man page for the `ls` command. When looking at a man page, type `q` at any time to quit and return to the shell.
Try out `man` by looking at any of the commands you've learned already (except `cd`\*). For example, `man ls` would open the man page for the `ls` command. When looking at a man page, type `q` at any time to quit and return to the shell.
The `man` command will be one of your most valuable tools for as long as you're using the GNU+Linux shell. You will always be learning new commands and new ways to use old commands, and `man` will help you do it.
@ -182,6 +200,7 @@ The `man` command will be one of your most valuable tools for as long as you're
## Commands have options and arguments.
When you look at the man page for a command like `ls`, you'll see in the DESCRIPTION section a number of **options** that you can use to modify how the command works. They look like `-a` or `-h` or `-l`. Try adding the `-a` option to `ls` and note the difference:
> `ls -a`
The `-a` option now lists "all" contents of your directory, including "hidden" files (aka dot files). You could combine the three options listed above in the form of `ls -alh` to list "all" files, in "long" form, and display file sizes in "human" readable format. Most commands have
@ -195,6 +214,7 @@ Commands will often combine options and arguments, sometimes in specific sequenc
You already know that you get dropped into your "home" directory when you first log in. Your home directory is just one of many, many other directories on the system. All of these directories are organized under one master directory called the "root directory". The root directory is often referred to with a single forward slash, like this: /
You can list all the directories at the root level by using the `ls` command again, as follows:
> `ls /`
Want to check out some of the directories you see in root? You could either `cd` into them and `ls` the contents, or just `ls` the comments directly as follows:
@ -215,31 +235,32 @@ If you don't own a file, then you can't change its mode. This is a basic securi
For the files you own (i.e. the files within your home directory), you can change the file modes yourself. You do this using the "change mode" command, `chmod`.
Each file has three permission levels: for the file owner, for members of the file's group*, and for all other system users. For each level, you can permit any combination of "read", "write", and "execute" permissions.
Each file has three permission levels: for the file owner, for members of the file's group\*, and for all other system users. For each level, you can permit any combination of "read", "write", and "execute" permissions.
(/* Do a web search for GNU+Linux users and groups to learn more about this important concept.)
(/\* Do a web search for GNU+Linux users and groups to learn more about this important concept.)
You can change a file's mode with `chmod` one of two ways. The first is a symbolic way in which you add or subtract 'r', 'w', and/or 'x' (read, write, execute) to 'u', 'g', or 'o' (user, group, or other). For example:
> `chmod g+x filename.txt`
This gives 'execute' privileges to members of filename.txt's group.
You can also use `chmod` numerically, through which you may set the user, group and other permissions all at once. For example:
> `chmod 755 filename.txt`
This gives the owner read, write and execute privileges, and gives only read and execute privileges to group and other.
Use `man chmod` to get a fuller understanding of `chmod`.
To get an interactive, visual feel for numeric file modes, try the tilde.team file mode widget:
https://tilde.team/~cmccabe/mode-gui.php
To get an interactive, visual feel for numeric file modes, try the tilde.team [file mode widget](/~cmccabe/mode-gui.php)
--
Finally, remember that 'testing.html' file we made above? Let's use that as an example of how you can control who can view your files. Use the following to make the 'testing.html' file visible in your website:
> cd ## to return you to your home directory
`chmod 644 public_html testing.html`
> `chmod 644 public_html testing.html`
Now if you bring up the following URL (with your username) in a browser, you should see the testing.html file you made.
@ -273,7 +294,6 @@ Below are some other common programs you'll likely want to use. Most of these h
`motd` - list the message of the day, which on tilde.team displays all the other commands below
## some tilde.team specific programs
`bbj` - a bulletin board for asynchronous discussions
@ -284,7 +304,6 @@ Below are some other common programs you'll likely want to use. Most of these h
`chat` - open `weechat` preconnected to our irc
## Some shell use cases
And in this corner, we shall describe some common activities people perform in a shell... [Feel free to add here.]

View File

@ -32,41 +32,38 @@ New to the command line and all this webby cowfoolery? You're in luck! Here's a
### PC (windows)
* On a PC, you'll need to get an ssh client. [PuTTY](http://www.putty.org/) is a good one.
- host: tilde.team
* another option is to use [WSL (windows subsystem for linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
* or [git bash](https://git-scm.com) included with a standard git install
- [git bash](https://gitforwindows.org) included with a standard git install
- [msys2](https://msys2.github.io) is quite nice and has support for [mosh](https://mosh.org)
- another option is to use [WSL (windows subsystem for linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
### Linux
* Open a terminal. Try ctrl + alt + t.
* `ssh your_username@tilde.team`
* Enter your password.
- Open a terminal. Try ctrl + alt + t.
- `ssh your_username@tilde.team`
- Enter your password.
### Mac
* Browse to Applications/Utilities/Terminal and launch Terminal (or press cmd+space, start typing Terminal, and press return)
* `ssh your_username@tilde.team`
* Enter your password.
- Browse to Applications/Utilities/Terminal and launch Terminal (or press cmd+space, start typing Terminal, and press return)
- `ssh your_username@tilde.team`
- Enter your password.
## Finding your index.html file
## Finding your index.php file
There are some basic command line commands you'll want to Google and learn, but for this tutorial you only need a few:
* `ls` = list files and folders in current directory
* `cd` = change directories
* `nano` = a command line text editor
- `ls` = list files and folders in current directory
- `cd` = change directories
- `nano` = a command line text editor
Type: `ls` to see where you are. You should see a directory called "public_html"
Type: `cd public_html` to move into that folder. (cd stands for change directory.)
Type: `ls` to see where you are. You should see your index.html file
Editing your index.html file
Type: `ls` to see where you are. You should see your index.php file
Editing your index.php file
Type: `nano index.html` to open your index.html file and begin editing
Type: `nano index.php` to open your index.php file and begin editing
Edit your file, willy nilly