contrl-d -exit logoff
Proper way to shut down in linux:
1. Become root
2. sync (data in memory sent to disk)
3. reboot then enter
cp
-to copy file
cp <file to be copied> <destination>
cp copy cp /mnt/d/htmlproj/frore.htm/home/httpd/html
Example:
cp /etc/passwd /mnt/floppy/password.txt
cp <path/filename> <destination path/filename>
First part of command is directory where the file is
Examples: /etc /mnt/floppy /mnt/cdrom
cp linux~.txt (name on floppy-can't use tilde ~ with linux-so you need to change
name) /home/ckoh/lcomm.txt
This copies text file to this subdirectory and changes the name-same content
File condensation and manipulation:
gzip - -zipped files gunzip -to unzip
tar -tarred files, compressed files
Examples: mfm1.3.tar.Z freedom_desktop.tar.gz youngcpp.tar
to unzip a gzipped file (* .tar) or (* .gz) gunzip (filename) gunzip
motif.Z
to untar a tarred file (* .tar) tar-xvf titan(filename)
to both unzip and untar tar -zxvf titan(filename)
ln -link, soft link or hard link
ln [options] source [dest]
ln [options] source directory
hard links made by default if no option, switch
ln -s -soft link, does not come into play on boot
up
Generally speaking, use only soft link only
because if hard link fails to work on boot, then the computer may not boot up.
To create a soft link to automatically boot up a program
Example: To have myslq daemon to automatically run at boot up
cd /etc/init.d
ln -s /etc/init.d/mysqld /etc/rc.d/rc3.d/S81mysqld
ln -s source target destination and program to start. Use capital S to start automatically. Use
any number but must be different from other numbers in other scripts
ls
-list
switches:
ls -l -long names Gives description so you can tell directories from files and
other information
ls -a -show me all files including hidden files shows dot files which start with
period
mount
-mount a drive
Examples:
mount /dev/fa0 mnt/floppy
To mount floppy
Become root
mount /mnt/floppy
To see contents of floppy
ls /mnt/floppy
mv
-move, rename (use with great caution, dangerous command)
Change file name with mv and move file -powerful command-be careful
mv <old filename> <new filename>
mv <path/filename> <newpath/filename>
mv removes a file or moves it from one directory to another
mv -i oldname newname
mv -I filename directory [/newname]
more less ( 2 separate commands)
more less - use commands to see longer files
in an orderly way
Use spacebar to go to next section
cat /etc/hosts cat only for short files
more <filename>
less <filename>
rm (remove)
rm <filename> Will ask you for confirmation
rm -f Will force delete-won't ask
rm-r delete all subdirectories and files -powerful command be careful
rm -fr - " " -will not ask for confirmation
* means everything like DOS
Ex: rm -f *
rpm
-package for installing programs
-Installing-uninstalling RPM-s are are proprietary to Red Hat. It stands for
Red hat Package Manager.
1. Download using Netscape or ftp. In Netscape, hold down shift key when
downloading rpm.
2. Install rpm install /rpm -i- You can save time by typing only 1st 2 letters
of name of rpm-then hit tab key.
3. To uninstall use rpm -e <name of file>
How can I install an rpm off of a FTP server?
RPM supports the use of ftp on the command line to update packages. Keep in mind
you must have a network connection of some kind for this to work. :-)
Format:
rpm (options) (pathname)
Example:
rpm -uvh ftp ://ftp .redhat.com/pub/redhat/redhat-4.0/updates/i386/ghostscript-3.33-3.i386.rpm
In general, normal usage of the rpm command can be summarised as follows:
---Installation/Upgrading/Removal
To install a package: rpm -ivh <filename>
ex: rpm -ivh somepackage.1.1-4.i386.rpm
To upgrade a package: rpm -Uvh <filename>
ex: rpm -uvh somepackage.1.1-5.i386.rpm
To remove a package: rpm -e <packagename>
ex: rpm -ivh somepackage
Also for upgrading or installing some packages you may need to use
additional flags to force the install to happen. It is only recommended to
use these if you know why these flags were needed.
--force -will overwrite files that are owned by other packages.
--nodeps -will install even if the package needs packages that were not
install ed.
---Querying
To see if a package is installed
ex: rpm -q <packagename>
ex.rpm -q somepackage
To get info on an installed package:
ex: rpm -qi <packagename>
rpm -qi somepackage
To list which files belong to a package:
ex: rpm -ql <packagename>
ex: rpm -ql somepackage
To see what package a file belongs to: rpm -qf <path-to-filename>
ex: rpm -qf /usr/bin/some_executable
One can usually join various query commands together, so
rpm -qil
will give information and list all the files in the package.
To look in a rpm filename that isnt install example, you tag on the p to the
query line.
ex: rpm -qilp somepackage.1.1-4.i386.rpm
-will list the information and the files contained in somepackage.
Note: More advanced usages can be found in the man page for rpm and at the
web site: ftp.rpm.org
--Verification
To see what files on the system may have changed from their initial
settings you can use RPM, to check up on them.
rpm -Va
will give you a list of all files that have changed in one form or
another since the package it is associated was install ed. This can be
a lot of files (and a lot may be changed due to post installation
work). To just see what packages have changed so that you can verify
them more individually, you can do the following:
rpm -Va | awk ''{print $2}'' | xargs rpm -qf | sort -u &> /tmp/file1
Then look in the file /tmp/file1 for which packages have had changes
from them.
shell
-terminal which has functionalities communication terminal to communicate
with a computer
The command interpreter used to pass commands to an operating system; so called
because it is the part of the operating system that interfaces with the outside
world.
.bashrc is the main shell configuration file for a user (there are other shells
of course)
cat .bashrc command to see file
cat bashrc | more to see file one screen at time
cat bashrc | less to scroll
man (topic) ex: man gzip -manual, to go to manual To access help files in
both unix and linux
Miscellaneous and Summaries of Commands:
Bin-binary all executable programs
Ways to look at directory contents:
1. go to directory with cd >then ls
2. ls /directory
ex: ls /mnt ls-l /mnt ls -al lists hidden, long filenames
^ up arrow-goes to previous screen
clear -clear screen
# Use this symbol if you want to comment this out. For your information not for
linux to read
To create directories -Go to where you want the directory to be
- or type path /mnt/floppy/gofaq.txt
Use mkdir (make directory)
rm removes filename
rm -i asks you to confirm that you want to delete each file
rm -i <filename> rm -fr remove, forcible recourse
Contrl-d -go back to other available user
man -show manual, help files ex: man gzip
pico -editor Use pico -w to help prevent mistakes in editing.
pine - popular email client
gzip gunzip zipped files
.tar tar -xvf tar zxvf tarred files
startx -start in graphic mode
| pipe =command switch Ex: dir | more
root-every directory can have a root -can mean root directory -or the root is
superuser. The Unix superuser account (with user name "root" and user
ID 0) that overrides file permissions. The term avatar is also used. By
extension, the privileged system-maintenance login on any operating system.
cd (and space) will take you back to home directory
cd .. Takes you back to prior directory
su (enter)-to become super user or change to
different user
Cntrl-d -to go back to ckoh user
Cntrl-d -to go back
ifconfig -shows interface configuration for network
Network shownand meaning:
lo -loopback-virtual interface
etho-o -physical card, hardware address given, recognized in BUS
inet address-IP address of card
broadcast address
ls -list
ls -l -list in long form, this shows permissions for files and
directories:
ex: drwxr-xr-x 2 root root bin -d is for directory-then permission-user- bin is name
of directory
devices: cuu -comports
cui -com interfaces
fd -floppy drives
tape -tapes drive
hd -hard drive
If you want to see what users exist, here is the command: more /etc/passwd
This will display the file which contains info about all the users.
If you want to add user nick, here's what you do:
adduser nick (must be root to add user)
passwd nick -to give
password to nick
where is -searches anywhere on the computer
which-searches only in your defined path
Find-keyword search from where to search
Ex: find / -name -file -number -size -pattern mysql -print
-file
Find path expression
File /etc/init.d/mysqul like right mous click an go to properties
What is your current path echo $ PATH
To add path put -use command line or file
User profile in .bashrc
.bashrc -user specified alias and function
/home/user/.bashrc
PATH=
First have to put path you already have.
You have to log out and back in to take effect
To see other machines
mount 192.168.1.30:/texts
Samba -to communicate with Windows machines
/etc/samba/smb.conf
to start mysql -database
/etc/init.d/mysquld start
Modules:
lsmod -list modules
modinfo -d -to find information about particular modules
insmod -to load a module
To see partions: fdisk -l
mount -shows what disks are mounted
mount/ unmount
Not disk system, devices are file systems.
If floppy is blank, unix cannot
recognize unlike DOS.
To see what's on floppy:
Commands
mount /dev/fd0 /mnt/floppy -to see floppy
mount -t msdos
dev =shows list of possible devices
mnt/floppy mnt/zip
at prompt type: cp .streprc /mnt/floppy/steprc.txt
at prompt type: unmount /mnt/floppy
startx -start x windows to go to graphic mode
up arrow -brings previous commands
down arrow brings forward commands
vi -editor (learning curve needed)
pico -easier editor Always use pico-w so there won't be wordwrap and
mistakes can be made
date -shows date and time
More File manipulation commands
cat - Concatenate and display a file
chmod - Change the permissions mode of a file
warning:
dangerous command
chown - Change the owner and/or group of a file
warning:
dangerous command
cp - Copy a file
diff - Display differences between pairs of text files
grep - Search a file for a specific text string
mv - Move or rename a file
warning:
dangerous command
rm - Remove a file
Display commands
date - Print the date and time
finger - Display information about a user
head - Display the first few lines of a file
less - Browse a text file
ls - List the contents of a directory
man - Display a reference manual page Example: type man copy to
understand copy command To advance each section, use spacebar; to quit, type q
more - Display a text file
pwd - Display the working directory pathname
tail - Display the end of a file
who - Display who is on the system
Process commands
exit - Terminate a process
kill - Terminate or send a signal to a process
passwd - Create or change a password
ps - Display the status of a process
ex: ps -ef | grep sendmail To see if sendmail
is running
ps -aux -show all processes running
telnet - Connect to a remote system using the Telnet protocol,
dangerously open
ssh- secure shell -secure remote access, much safer
Don't use mail command-this communicates directly with mail daemon
mail -checks mail mail <email address> send mail
-v (verbose) to see what's here
Can use pico for mail body
daemon is continuously running program.
cntrl -l check mail with Pine mail program
> is directing command
TAB Use tab key to complete command
Use arrow keys:
^ Use up arrow to bring up previous command
v Use down arrow to go down in history of commands
history -to see history of commands-you can scroll through with up and down
arrows
Use Cntl-alt-backspace to get out of GUI quickly
Network
Commands to use to see network setup:
ifconfig-a shows network setup but be careful since ifconfig also used to
configure network setup
cat /etc/sysconfig/network
cat /etc/hosts
Note: To find more linux information:
Linux CD has how to files as documents
http://www.linux.org -has howto files
Summary network commands:
/mnt/d hdb1
netstat
ifconfig
From linux notes:
SSH -secure shell Used like telnet
but more secure. You exchange keys.
SSH is NOT like FTP, It is NOT like Telnet. It is "Secure Shell"
Telnet is does NOT run as a daemon. This is why you will not find a PID to kill.
Here are the steps to disable Telnet;
1. Edit the file; /etc/inetd.conf. Comment out (#) the line containing the word
"telnet". Save the file
2. Reboot
You can change the shell.
Try Ctrl-F1, F2, F3, etc
You should be able to switch shells.
You first do ps aux | grep sendmail
Then you note down the PID number, which is in the first column
Then you do kill PID#
After you create a user, you have to type: passwd <username>
cat /var/log/messages | more