Appendix B: Linux and DOS Information

Linux Commands

&—when used after a command, it launches the command in the background.

! (bang)—used to retrieve a command from the history list. !! retrieves the last instruction, !#, where # is a number that retrieves the instruction # from the list.

~—used to denote a user’s home directory. When used as ~username, it denotes username’s home directory.

.—used to indicate the current directory, as in cp ~foxr/* . (copy all files in foxr’s home directory to this directory).

..—used to indicate the parent directory, as in cd ../.. (move up two levels in the file system).

apropos string—display all commands whose description field contain the given string; used to identify a command when the name of the command is not known.

bash—start a new bash session in the current window.

bg number—where number is an integer number; it moves the job corresponding to number to the background.

cat item(s)—concatenate the items specified (items are typically file names), default output is sent to the screen.

cd path—change directory to the directory given in path. If path is an absolute path, then you are changed to that directory. Otherwise, you are moved relative from where you currently are (pwd) to the new location. The use of .. moves you up one level in the file system.

chgrp group item(s)—change item(s)’ group ownership to the given group.

chmod modification item(s)—change the item(s)’ permissions to the given modification. Can be specified in one of three ways:

1. Using +/– with ugo and rwx

2. Using = with ugo and rwx

3. Using three digits as in 755 to denote owner, group, world

chown owner item(s)—change item(s)’ owner to given owner.

configure—execute the configure script to create a makefile, issued as ./configure followed by any desired parameters. Parameters are software specific. See make and makefile.

cp source target—copy file(s) listed as source to target. Target is typically a directory although if source is a single file, target can be a new file name. Two options of note are –i for interactive mode (prompt the user before overwriting a file that may already exist) and –r for a recursive copy (if source is a directory, it not only copies the contents of the directory, but all subdirectories).

echo string—output string to screen. The string can comprise literal values, variables (with a $ before each variable name) and Linux commands. When placed in ‘’, output all items literally. When command is placed in ` `, execute command and use its output as part of the string.

exit—leave the current bash session. If another session exists in the same window, you will resume it, otherwise the window will close.

fg number—where number is an integer number, it moves the job corresponding to number to the foreground.

find path options—the find command searches for files that fill some criteria, the path is the starting point of the search, you might use your home directory (~) or you might start at root (/). Keep in mind that if you run this program without being root, some directories and files may not be accessible by you. The options that you most likely will use are –name string to specify that you are searching for all files with string in their name followed by –print to output the list of files found.

fsck—file system check, used to check the integrity of the file system.

jobs—list all active processes in the given terminal window, often used along with fg and bg.

gcc—the GNUs C compiler used to compile programs. g++ is the GNU’s C++ compiler.

grep expression file(s)—match the regular expression to each line of the file, returning any matches. egrep uses the extended regular expression set. Common options include –e (same as using egrep), –c to output just the number of matches, –i to ignore the case of the letters, and –n to output line numbers for each match.

gzip/gunzip filename—zips/unzips filename.

history—display the history list.

ifconfig—may require /sbin/ifconfig—display network interface information for computer including IP address.

kill signal pid—kill the process of the given process ID using the given signal, signal is often –9.

less filename—like cat, displays filename to the screen, but pauses at each screen. You can also use the arrow keys to move up and down in the file. The command more is similar but cannot step backward.

ln [–s] filename linkname—create a link (symbolic link if –s is used) from linkname to filename.

ls filenames—list the filenames provided. ls by itself lists all items in the current directory. ls permits wildcards for filename expansion such as ls *.txt. Common options for ls are given:

ls –l—long listing

ls –a—include “hidden” files (filenames that start with a dot)

make—run the makefile script to compile software, options include make all, make install, make tar.

man command—provide the manual page for the given command.

mkdir dirname—create the directory named dirname in the current directory.

mount physical logical—a command to mount a partition indicated by physical (the actual name of the file system) to the file system at the location logical. The command umount is used to unmounts a partition. mount –a mounts all partitions found in the file /etc/fstab.

mv source destination—move the item source to destination. If destination is a filename, then this is a rename operation; otherwise, the file is moved to the new directory.

nice value command—execute command with the niceness value of value. Can also adjust a running process using nice –n value PID.

nslookup alias—query the local DNS for the IP address of the given alias. Can also be called as nslookup alias server if you want to specify a different DNS.

passwd username—prompt the user to change username’s password. If username is omitted, then change the current user’s password. Unless you are root, you will be required to enter username’s password before changing it. Options include:

-l—lock the account so that only root can access it

-u—unlock the account

-d—delete the password for the account

-x—establish an expiration date for the password (a date by which the password must be changed)

-w—establish the number of days in advance that the user will be warned to change passwords

ps—process status information, that is, output the running processes. There are many options available. The ps command by itself only prints processes running in the current terminal window owned by the current user. Other options of note include:

a—print processes of all users of the current window

f—denote parent-child relationships using ASCII “art” output

u—user “user-oriented format” for output (see below)

x—print processes no matter which window or console it originated from

Using option u outputs processes by user name, PID, %CPU usage (the percentage of time it has been running versus waiting), %memory usage (as a percentage of the computer’s main memory capacity), total amount of memory usage, virtual memory utilization, the console that started the process, the process’ execution status, the date that the process started, the amount of CPU time it has used, and the process’ name.

pwd—print working directory.

Redirection—although this is not a Linux command, you can use redirection in your Linux commands in order to alter the standard input or output of a command. The redirection operators are

>—redirect output to the given file as in cat foo1.txt foot2.txt > foo3.txt.

>>—redirect output to append to the given file.

<—redirect input from keyboard to the given file.

<<—redirect input from file to keyboard, end input after given string is reached, as in cat << quit > foo.txt, which will allow the user to enter items until the string “quit” is entered.

|—a pipe, take the output of one Linux command and use it as input to another, such as ls –al | egrep “rwx”, which takes the output of the ls –al command and uses it as input to the egrep command.

rm item(s)—remove (delete) the item(s). Options include –r for a recursive delete (this deletes subdirectories and their contents recursively), –f to delete without permission, and –i to delete interactively—that is, to ask the user before deleting each item.

rmdir item—remove the given directory. This is only available if the directory is empty.

service servicename command—command to change the service servicename. The command is one of start, stop, status, and restart.

ssh host—open a secure shell communication with host using encryption. This has replaced telnet, which opens communication with a host but without encryption.

su [username]—switch to username’s account. If username is omitted, switch to root. The instruction requires that you provide the account’s password (unless you are currently root).

sudo username command—literally, this command executes command as username, that is, it executes the specified command as if it was issued by the given username. Commonly, this command is used without username so that the command executes as if issued by root. An entry must be placed in the file /etc/sudoers that specifies that the given user has access to the specified command. For instance, if zappaf were permitted to use useradd, the following line would be added to the suoders file:

	zappaf localhost=/usr/sbin/useradd

Before the command executes, the user is required to enter their password.

tar filename [source]—the tape archive utility bundles one or more files and directories into a single file. When the options –xf are used, the files/directories are extracted from the bundle and copied into the current directory. When used with –cf, a new tar file is created from the entry(ies) listed under source. For instance, tar –cf foo.tar /myfiles would take all of the files in the subdirectory myfiles along with the myfiles directory and place them into foo.tar. An added option, z, will gzip or gunzip the files (gzip when used with –c and gunzip when used with –x). –c stands for create, –x for extract.

useradd options username—create a new account with the name username. This instruction can only be executed by root. The instruction adds associated entries in /etc/passwd, /etc/shadow, and /etc/group. The command has many options including:

-m—create a home directory

-d dir—use dir the in place of the default directory

-s shell—use shell in place of the default log in shell

-G groups—add user to the list of groups (the list is separated by commas but no spaces)

-c comment—add comment to the /etc/passwd file, usually used to specify the user’s full name

-p password—use the encrypted password for an initial password

-u uid—give the user the specified uid (user ID)

userdel username—delete username’s account. The option –f forces the deletion even if the user is still logged in and –r removes the user’s home directory and e-mail files along with the user account.

usermod options username—modifies username’s account based on the options specified. These options are the same as in useradd.

vi—launch the vi text editor (also vim). Emacs launches the Emacs text editor.

wget URL—download the file specified by the URL. Similar to entering an http request in a web browser except that the file is stored to disk.

who—lists all usernames of currently logged in users.

whoami—outputs the current user’s username. This is useful if you cannot remember who you are if you have used su.

yum command package—the Yellowdog Updater, Modifier program is used to install, remove, and update software packages. Command is usually one of install, update, check-update, upgrade, remove, list, info, clean, or reinstall. The yum program uses the rpm program.

Linux Files and Directories of Note

/etc/group—file that stores all group information.

/etc/init.d—a Linux directory where services are stored.

/etc/inittab—the initialization script first executed after the Linux operating system boots, it is responsible for setting the runlevel.

/etc/passwd—file that stores all user account information (excluding user passwords).

/etc/rc#.d—a set of directories in Linux which stores symbolic links to services that should be started or stopped at system initialization time. The # is the run-level, one of 0–6.

/etc/rc.sysinit—a script executed during system initialization that starts and stops services.

/etc/shadow—file that stores all user passwords in an encrypted form.

/etc/syslog.conf—the configuration file for the syslogd service that logs application software and non-kernel operating system messages.

DOS Commands of Note

cd or chdir—change directories, used with a path as in cd ..fooar. See also C:, D:, etc.

chkdsk—checks the specified disk for file system integrity.

cls—clear the screen.

copy—copy a file from one location to another in the file system. Wildcards are permissible.

C:change to the C: partition. D:—change to the D: partition. This also applies for any other partitions.

del (also erase)—delete the given file(s). Wildcards are permissible.

dir—list the contents of the current directory or the given directory if a path is supplied.

echo—output the given string and/or variables to the screen.

edit—launch the DOS text editor program.

exit—can be used to exit the DOS window if running DOS within windows.

format—to format a disk. WARNING: formatting a disk erases its contents.

help—gives general help on DOS. help command lists command’s help page.

md (also mkdir)—create a new directory.

mem—display memory usage information.

more—displays contents of a file, one screen at a time.

move—move a file to a new location. If the new location is the same directory, this performs a rename. The ren instruction is a rename instruction.

path—display the contents of the path variable. Can also be used to set new paths in the variable.

print—sends a specified file to a printer.

rd (also rmdir)—remove an empty directory.

undel—undelete a previously deleted file. This works on files that are “recoverable” only. A deleted file may or may not be recoverable based on the amount of time that has elapsed since the deletion.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.107.229