very brief intro to Linux
The following pages go through the basic Linux stuff to get you up to speed on things and terms that people may throw about.
File structure:
Linux has a slightly different file structure from Windows. It doesn't have "drives," like C: or D:. Instead, it has one main drive (/), and everything else is mounted within that
A quick look at the directories:
/: The "root" of your filesystem. This is where everything begins and is stored; everything else branches out from here. / has no parent directory.
/dev: Since everything appears as a file in Linux, this is where devices appear (a device being a sound card, virtual terminal, GPS, USB drive, hard disk, etc.). You can't really do anything directly to these devices, but knowing if they exist or not is a good way to tell if drivers loaded OK or if the device is recognized at all.
/mnt and /media: This is where external things are mounted, such as CDROMs and USB drives. They would be mounted in subfolders, like /media/cdrom for a CD.
/etc: This subdirectory holds configuration files for just about everything.
/usr: Contains most user stuff (programs, libraries, etc.).
/usr/bin: Most executables go here
/usr/lib: Most libraries go here
/usr/include: Development headers for compiling go here
Devices
Everything in Linux is a file, even your hard drive (yes, your hard disk has a file representing itself on itself). This section covers these such files, the ones representing hardware and other devices.
These files, as stated in the previous section, are found in /dev, or the folder called "dev" in the very bottom or root of the drive. The following is a list of common files found there, what they are, and what you can do with them.
/dev/hdXN and /dev/sdXN: These devices (such as /dev/hda1 or /dev/sdb3) are hard drives/USB drives and partitions. X is a letter, starting from "a," then moving on as more devices get added. For instance, /dev/hda is the first IDE/CF drive in the computer, and /dev/hda1 is the first partition on that drive. N is the number of the partition.
USB devices appear as /dev/sdXN, as do SATA drives. SD/MMC devices appear as /dev/mmcblkXpN, but in that case X is a number as well (starting from 0). CF cards appear as IDE devices, or /dev/hdXN.
What you can do with them: There are several things to do with these devices, but the most common is to mount it, or make the drive accessable. You do that through the mount command:
mount /dev/deviceandpartition /mount/point
You can also format them, eg:
mkfs.ext2 /dev/sda1
will make an EXT2 filesystem on the first partition of the first USB/SATA device.
The Command Line
The command line is a commonly used tool in Linux, and, quite contrary to popular belief, it is NOT hard to use or frightening. This section will (hopefully|attempt to|try to) get you up to speed on the CLI (Command Line Interface).
Commands: A command is simply something you type into the CLI, such as "ping" or "grep." It may give useful output, run a program, or do something else.
Command flags: A flag is simply something you pass to the command to tell it to do something special or different. Take the example:
ls -l -h
In this example, 'ls' is the command (it lists the files in the current directory), and 'l' and 'h' are the flags. The '-' in front of the 'l' and 'h' mean that they are flags and not arguments. This command could actually have been written
ls -lh
because most Linux commands allow you to squish the flags together after the dash. That won't always work, however, if the flag requires an argument:
ping -c 4 127.0.0.1
You couldn't just add a random flag before or after (this may be false) the "c" and expect it to work fine (in this case, the 'c' flag means to limit the number of pings, and 4 is the argument given to that flag telling it how many pings to limit itself to).
In general, the 'h' flag (-h, or --help) gives information on what flags are available for the program and what they do:
#command -h
usage: command [flags] ARGUMENT [argument2...]
#
In this example, you run 'command' and optionally pass flags (the brackets mean optional), then give it an argument, optionally with more arguments.
Arguments:
Command reference: http://tyrannozaurus.com/node/181
something
A
B
C
cd NEW-DIRECTORY
Changes the working directory to NEW-DIRECTORY. If no argument is given, it will change you to your home directory.
clear
Clears all the text from the terminal screen (it is still stored in the scrollback buffer, however)
cp [-r] FILE|FOLDER PLACE|NAME-TO-COPY-TO
This command takes two arguments and copies the first one (the file, FILE|FOLDER) to the location and/or name specified in the second argument (PLACE|NAME-TO-COPY-TO). The -r flag can be passed if you wish to copy a directory.
D
df
This command will print information about what devices are mounted where and total/free space. Add the -h flag to print the space info in MB/GB instead of bytes (easier to read).
E
exit
Quits the shell (and, unless other tab are open or some other circumstance, the terminal)
F
fdisk DEVICE
This command starts the fdisk program to change partitions on a disk. The DEVICE is /dev/xyz (where xyz is NOT xyz1, xyz2, etc., eg no number).
free
This command prints out how much RAM/swap is available/used.
G
grep SEARCH-TERM FILE
Grep prints out every line SEARCH-TERM appears on in file FILE. If SEARCH-TERM is more than one word, you must put quotes around it.
H
I
insmod /FULL/PATH/TO/MODULE.ko
This inserts the given module into the kernel, similar to modprobe, but needs the full path to the module.
J
K
kill [-9] PID
Stops the process with the ID PID, which can be found with "top." The -9 flag can be used to force the stopping if the program is really locked up.
killall APPLICATION-NAME
Stops the process corresponding to APPLICATION-NAME. Works well if used with "top."
L
ln -s
Makes
ls [-a] [
Lists the files and folders in the current directory (or whatever directory you specify with the optional
M
mkdir [-p] DIRECTORY
This command makes the directory DIRECTORY. If you use the -p flag, you can make a tree of directories, otherwise the outermost directory's parent directory must exist.
modprobe MODULE
This command loads the module MODULE. Underscores and dashes are treated the same. A smarter version of insmod.
mount DEVICE [LOCATION]
This mounts device DEVICE (/dev/xyzn, eg WITH the number) at location LOCATION. If the device is in /etc/fstab, you do not need to specify LOCATION (and have admin rights).
mv FILE|FOLDER DESTINATION
Move. This command moves FILE|FOLDER to DESTINATION. It is also used to rename a file (eg, "mv abc xyz" will rename abc to xyz).
N
O
O
P
ping HOSTNAME|IPADDRESS
This sends network packets to the given host, testing network connectivity.
ps aux|grep SEARCH_TERM
This command is good for finding process IDs. On full linux systems, "ps aux" lists more detail about the processes than does the straight "ps" command, and then by piping it through grep, you filter out all but the ones you're interested in.
Note that the busybox version of "ps" does not accept any arguments, so the same thing can be accomplished on Zaurii which only have the BusyBox version of "ps", by entering: "ps | grep SEARCH_TERM"
If you have a fully featured version of "ps" and just are looking for a particular application or command process, then it makes more sense to enter the command "ps -C COMMAND"
pwd
Print Working Directory The command prints your current working directory.
Q
R
R
rm [-r]
Remove. This command removes file
rmdir DIRECTORY_NAME(S)
This command removes a directory or set of directories. It will not remove the directory if the directory (folder) contains any files.
S
T
top
Shows information about running processes.
U
umount device|mount-point
This command unmounts (notice that the command is "umount," no "n") the device specified, or the device mounted at mountpoint mount-point.
uname -a
Prints out a bunch of potentially useful information about your system, including kernel version. See the output of "uname --help" for which flags to use to get specific information.
V
W
wget URL
Downloads the file at
whoami
Prints the current user's name
X
Y
Z