external links: index -|- commands -|- home -|- end
Just some commands used, in alphabetic order - internal links :
dir dmesg editor
env export find
glxinfo kill ls lspci
mount netcardconfig ps rm rmdir
root set shutdown
tar x-windows
This is more a personal web-log of useful commands found and used, rather than any attempt at a 'definitive' index, or in any way giving the full specifications of any particular command ... TAKE CARE WITH USE ;=)) Of course, each shell command line ends with the <enter> key, not shown in the examples ...
Note: Some sample outputs, by dmesg, glxinfo, lspci and set were made while running KNOPPIX 3.8 Live on a Pentium III 600 MHz machine ... these files have had DOS line endings, that is a CR/LF, added ...
To mount an existing file system in linux, the command is 'mount', and
you must have root privileges, or use sudo (super user do) ... The
basic command is -
...$ [sudo] mount [-t <type>] <file-system-name-to-mount>
<path-where-to-mount>
You must also know the 'type' of file system. These seem to be -
Windows | Linux |
FAT (or FAT16) | msdos * |
FAT32 | vfat |
NTFS | ntfs |
* Below indicates perhaps this should be 'umsdos'!
but in other postings have see just 'msdos' ... |
A fuller list is given below. To find the device names to use in the mount, find the file system table file -
...$ find / -type f -name fstab
...$ cat /path_to_fstab/fstab
Several files may be found, but it is usually in /etc/fstab ... In this file you should find entries like -
/dev/fd0 /media/floppy auto users,noauto,exec,umask=000 0 0
/dev/cdrom /mnt/cdrom auto users,noauto,exec,ro 0 0
/dev/hda1 /mnt/hda1 vfat noauto, users,exec,umask=000,uid=fglive 0 0
/dev/hdb1 /mnt/hdb1 vfat noauto, users,exec,umask=000,uid=fglive 0 0
/dev/hdd1 /mnt/hdd1 vfat noauto, users,exec,umask=000,uid=fglive 0 0
/dev/hdd5 /mnt/hdd5 vfat noauto, users,exec,umask=000,uid=fglive 0 0
This tells us the floppy device is called /dev/fd0 ... the two existing hard disks in that system C: and D:, are called /mnt/hdd1 and /mnt/hdd5, and are of the type vfat (that is FAT32 of Windows 95/98+)
(a) To mount an existing FAT (FAT16) drive to the unix file system
.../...$ cd /mnt
.../mnt$ sudo mkdir d1
.../mnt$ sudo mount -t msdos /dev/hdd5 /mnt/d1
(b) For FAT32
.../mnt$ sudo mkdir d5
.../mnt$ sudo mount -t vfat /dev/hdd5 /mnt/d5
(c) A Floppy drive
.../mnt$ sudo mkdir f1
.../mnt$ sudo mount /dev/fd0 /mnt/f1
To remove this floppy drive, which you should do when changing the disk, else you will get all sorts of error messages popping up ;=)) -
.../mnt$ umount f1
(d) To mount the CDROM
.../mnt$ sudo mkdir cd
.../mnt$ sudo mount /dev/cdrom /mnt/cd
In this case I got an advice -
mount: block device /dev/cdrom is write-protected, mounting read-only
That makes sense ... ;=))
Indications are that the file systems supported by any particular kernel can be found in the file /proc/filesystems, but have yet to check this. When mount -t iso9660 /dev/cdrom /cdrom failed for one person with message mount: unknown filesystem type 'iso9660', and it could not be found in the file /proc/filesystems, another user suggested re-compiling the kernel - go into /usr/src/linux, and do make menuconfig, make, and make modules_install - and it should be done ;=)) the filesystems currently mounted should be in the files /etc/mtab and /proc/mounts ...
From http://linux.about.com/od/commands/l/blcmdl8_mount.htm found this quote - 'The file system types which are currently supported are: adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, xiafs. Note that coherent, sysv and xenix are equivalent and that xenix and coherent will be removed at some point in the future --- use sysv instead. Since kernel version 2.1.21 the types ext and xiafs do not exist anymore.' ...
And goes on to say 'In order to make it possible to treat all types in a uniform way, mount will execute the program /sbin/mount.TYPE (if that exists) when called with type TYPE. Since various versions of the smbmount program have different calling conventions, /sbin/mount.smb may have to be a shell script that sets up the desired call.' ...
And rather than using 'sudo' all the time, which seemed to fail with 'permission denied' on re-direction of something to a file on an existing hard disks, that is using the '>' re-direction character, do the following to SETUP a root password, if not already done ...
...$ sudo passwd root
Enter password: pass
Re-enter password: pass
Then you can do to login as 'root' ...
...$ su root
password: pass
and you are now able to do things not possible before ... ;=)) when done
...# exit
puts you back as a 'normal' user ...
Note, in some systems the prompt changes to a '#' when logged in as root, while a '$' indicates a normal user, but am unsure if this is always like this ;=)) It probably depends on what is in your $HOME/.bashrc, or some other shell initialization file. Some systems, like KNOPPIX 3.8 Live have no root password set, thus 'su root' will immediately log you in as 'root' ;=()
You can also login as 'root' using -
~$ sudo -i
and then entering your 'root' password at the prompt. And exit as root with 'exit' ...
In most 'desktop' GUI applications there will probably be a menu item for this - in Kubuntu for example, there is a 'Log Out' choice. In X-windows in general, there will usually be a menu item to exit all running applications, and return you to the 'root' shell. In the root shell the command is 'shutdown', plus options ...
...# shutdown -h -P now
This will use the default time delay between the TERM signal sent to any running processes, and the KILL signal ... the -h is to HALT, the -P is to turn off the power, and 'now' means exactly what it says ... Of course some older machines may not support the 'power-down' and you will have to switch off the machine.
A shutdown and reboot can be done in a shell with :-
~$ sudo reboot
To delete a file -
...$ rm filename
To delete a directory, folder ... it must be empty ...
...$ sudo rmdir dir-name
To delete an entire directory, and all it contents, try -
~$ rm -rd dirname
These may not be the same on all systems, but having had the problem that a COM4 mouse FAILED to load under a 'live' linux system, I had to 'discover' what keystrokes did what ... ;=))
Alt + Shift - Opened what is called the system menu in windows, and this contained the following commands
Alt + F11 - Full screen toggle
Alt + F4 - Close window
Alt + F7 - Move the window with cursor keys. <enter> key to end move.
Alt + Ctrl + Esc - Window List
There are a WIDE variety of editor available in unix/linux, and it is hard to choose ;=))
At the moment, I use Kate. It has some color coding, and it does a little auot-indenting
A: This simple text editor, pico, (or nano) is/are great, in that it/they has/have a status line with keyboard help. Most of the commands commence with the ctrl key ... simple usage ...
...$ pico filename
Also, as usual
...$ pico --help
will show a considerable list of command line options ... AS WITH MOST LINUX COMMANDS ;=))
B: Of course there is vi ;=()
This simple command prints some kernel messages ... usually it is too long to view in a terminal, so I usually log in as root, mount the existing hard disk(s) into the distribution, if not already available, and write the messages to a file on that disk, like :-
...# dmesg > /windows/docs/dmesg.txt
...# nano /windows/docs/dmesg.txt
Of course, if the particular distribution does not have 'pico', or 'nano', then there is always 'vim' ... just REMEMBER in vim, the commands commence with ':', like :q should QUIT, or :q! to exit without saving changes ... this site - http://www.tuxfiles.org/linuxhelp/vimcheat.html - has a list of the vim commands ... sample output - dmesg.txt
The command -
...$ glxinfo -v
displays information about a GLX extension and OpenGL renderer. ... I have found that one of the most important pieces of information for real time image programs, like FlightGear, is 'direct rendering: [Yes|No]' ... since applications like FlightGear use 'direct rendering' to display the moving scenery, they will not run when this is 'No' ... sample output - glxinfo.txt
The command -
...$ lspci -vv
is a utility for displaying information about all PCI buses in the system and all devices connected to them ... sample output - lspci.txt
The command -
...$ set
or
...$ env
will list all the current environment variables. Some 'interesting' items are HOSTNAME, HOSTTYPE, COUNTRY, etc ... sample output - set.txt - more on 'set'
The command -
...# netcardconfig
allows you to establish an IP address for the ethernet card ... if you choose not to establish it by DHCP, (Dynamic Host Configuration Protocol), then you will be asked to supply an IP address, and net mask, a broadcast IP, and finally a default gateway IP ...
This is a easy way to 'find' a file, directory, etc. As usual --help will list all the options available. Here is a command to find a file -
...# find where-to-search -type f -name name-of-file
Or if you want to find a directory, a folder, then
...# find . -type d -name name-of-directory
This sets a variable in the shell environment.
...# export VARIABLE=value
SYNTAX export [-fn] [-p] [name[=value]] OPTIONS -f The names refer to shell functions; otherwise the names refer to shell variables -n No longer mark each name for export. -p Display output in a form that may be reused as input.
If no names are supplied, or if the `-p' option is given, a list of exported names is displayed.
A list set as the shell starts can usually be found in etc/profile, or etc/.profile, and in each HOME (~) directory, in .profile, if it exists.
This utility packs or unpacks a 'tar' archive file. This is quite frequently in the form tar.gz, and the following commands uses ls to check the file exists, and then fully unpacks it ...
...$ ls fgcom-latest.tar.gz ...$ tar xvzf fgcom-latest.tar.gz ... ...$ cd fgcom/src ...$ make ... ...$ make install, or ...$ sudo make install
A command to create a tar ball, which is also gzipped, of all the files with a .sh extension, in the current directory, and all below it would be -
~$ find . -name *.sh -type f | xargs tar -cz -f /windows/doc/mysh.tgz
Note the use of 'find' to locate all the files, and pipe the list into tar using 'xargs' ...
A simple 'ls', or 'dir' command lists the filse and directories in a column fashion, which gives little information, like -.
...$ ls fgcom-latest.tar.gz other-files etc ...
Commonly I want to find a particular file, thus use the following -
...$ ls -ld p*
This would list all files and directories in the current directory. The -l denotes the long format, and the -d inhibits recursion into sub-directories, which is its default action.
Be aware, this with wild-card, '*', will only work if at least one file or directory exists beginning with the letter 'p', since the 'p*' is actually expanded by the shell, and not by the 'ls' command.
A simple -
...$ ps
will list only the few processes in that terminal.
But usually we will want all the processes -
...$ ps -A
will list everything running ... as usual type 'ps --help' to see the full list of options.
The normal method is to try a RUB key, '_' (type underscore, "_", by holding down SHIFT key). And some processes will abort on receiving a 'quit' signal. This can be sent by typing Ctrl+\ (type "\" while holding down the CONTROL key). The system deposits a file called 'core' when this happens. However, sometimes a process will ignore both of these keystroke-generated signals, then it is time for the 'kill'.
The general form is -
~$ kill -N PID
The PID can be found using the 'ps -A' command, and the normal N is 1.
Signal number `1', a 'hangup' signal, is recommended because it should kill the process and, if it is an editor, save the buffer. Signal number '9', a 'kill' signal, is the surest way to kill a process and is recommended only as a last resort since it will not save editor buffers.