Come to LUG!
Wednesdays 7:00 Klaus 1456
Linux is an open source kernel.
A kernel is the core of an OS that manages devices and io.
Ubuntu is a Linux distribution (or distro).
A distro is a collection of software which includes a kernel and other programs.
Personal Files
/home/user
C:\Documents and Settings\User
Program Files
C:\Program Files
Linux doesn't have just one spot for this.
/
|-- bin #system binaries
|-- boot #stuff for booting
|-- dev #device files
|-- etc #config files
|-- home #user files
|-- lib #shared libraries
|-- lib64 #64 bit shared libraries
|-- mnt #mounted file systems
|-- opt #optional software
|-- proc #process information (virtual file system)
|-- root #root user home directory
|-- run #info about running system
|-- sbin #system binaries
|-- srv #files to be served
|-- tmp #temporary files
|-- usr #second file system hierarchy
`-- var #variable files - logs
You can read more about the FHS standards at wikipedia.
linus@host:~$ cd Documents/Folder
The cd
command changes the current directory.
linus@host:~$ ls
Documents Downloads Desktop
linus@host:~$ ls --help
Man, I wish I knew how to use ... grep , find , and git.
Well now you can learn!
man command
Also run man intro
for a brief Linux intro.
mkdir directory
touch file
gedit file.txt
If you want to learn vim run vimtutor
for an intro.
cat file
The following commands can overwrite your files if used improperly.
rm file
rm -rf directory
mv old new
cp source dest
ln -s target linkname
Making a file executable
chmod +x program
You will use apt-get to install software on Ubuntu.
Other Linux distros might use something else.
Searching packages
apt-cache search program
Installing a program
sudo apt-get install program
Update package list
sudo apt-get update
Update all packages
sudo apt-get upgrade
Tar is program that compresses files into a .tar.gz. We will often give you tar.gz files and ask you to turn them in as well.
Compress
tar czvf archive.tar.gz list of files
Compress Ze Various Files
Extract
tar xzvf archive.tar.gz
Extract Ze Various Files
Allows you to run multiple programs from the same terminal.
Most terminal emulators support sending to a signal to a running process. This is what happens when you press Ctrl-C
This is more fun if you follow along on your own shell.
user@~$ sleep 2 # wait 2 seconds
user@~$ sleep 200 & # runs the program in the background
user@~$ sleep 100 # who wants to wait that long (presses ctrl-z)
^Z
user@~$ jobs
[1]- Running sleep 200 &
[2]+ Stopped sleep 100
user@~$ bg
user@~$ jobs
[1]- Running sleep 200 &
[2]+ Running sleep 100 &
user@~$ fg 1
How you can be faster on the command line.
Let's say your in a directory and need to delete all the .o files but you want to keep all of the other files.
rm -i *.o
Don't add the -i if you don't want it to ask you if you are sure.
Let's write a quick java program to find out!
Echo.java
public class Echo {
public static void main(String[] argv) {
System.out.println(java.util.Arrays.toString(argv));
}
}
To run and compile:
javac Echo.java
java Echo *
The shell expands words with * to all filenames with a matching regular expression.
Pipes are a way you can use the output of one command as the input for another.
This is one of the reasons people love the command line.
Filters are programs that process text.
List of common filters:
fortune | cowsay
You can stick this at the bottom of your ~/.bashrc
Bash features you don't need know about.
Binding | Action |
---|---|
C-a | Move cursor to start of line |
C-e | Move cursor to end of line |
C-u | Cut text before cursor |
C-k | Cut text after cursor |
C-y | Paste text from shell |
Don't get slowed down by your typing mistakes.
alias sl="ls"
Also alias long commands to save keystrokes.
alias a="sudo apt-get install"
echo why hello there
why hello there
echo !:2
hello
See more obscure ones here
Pressing ctrl-x ctrl-e will open vim for quickly creating a command. When you save and quit the command will be executed.