P. Bournias
Management Information Systems and Networking Technology


Areas of Consulting
Contact
Main Design's


LINUX RESOURCE #4

LINUX COMMANDS:

SPECIAL WARNINGS and NOTES:
Command parameters are case-sensitive and must be typed as seen.
e.g. fsck -AafC

If you are working on your system as root, you must always be careful when working with files as they have inherent OWNER & GROUP classifications that affect the system and security.

GUI BASED PROGRAMS AND X-WINDOWS

If it doesn't work, you need help from another user or expert.  No additional comments except that I prefer the Gnome Editor for work whereas KDE is considered to be more amiable towards actually configuring linux in gui mode.

involving cut & paste.  If you aren't up to working in DOS then you won't be up to working in unix/linux text based.   Your loss.

X BASED TOOLS:
startx starts linux gui

LOGIN:
root password: xxxxxxxx

LOGOUT:
Press ctrl-d or type logout

SYSTEM SHUTDOWN:
shutdown -h now shutdown the system completely now.
shutdown -r +5 shutdown system and restart after 5 min.
ctrl-alt-del shutdown and reboot
unless changed in the configuration to disable this functionality
shutdown [-t sec] [-arkhncfF] time [warning-message] note: -F forces fsck on boot
e.g.   shutdown -r 15 -F now  shutdown in 15 seconds and reboot with a disk check
This can be useful if you want to verify that your drive has not suffered any problems especially after a power drop, etc..

TEXT BASED NETWORKING TOOLS:
userinfo update 'gecos' or account info
userpasswd changing user passwords
linuxconf, netconf various network and control panel configurator
userconf an alternate user administrator

LINUX UTILITIES UNDER DOS:
rawrite   on CD \dosutils, to create boot image diskette
Druid     on CD \dosutils, to format hard disk partitions Fdisk on CD \dosutils,
           to format hard disk partitions

SAMBA
See smb.conf for configuration settings and change the following where necessary
Server host DOMAIN NAME
Server ip DNS IP
Share name printer_lp0
Also remember to create a user area using the examples at the bottom of the smb.conf file.
Workgroup workgroup

Testparm     to test parameter changes made to smb.conf file for validity
smbpasswd -a username     to give user a samba passwd to enable samba access

RE-STARTING SERVICES to avoid re-boot after config file changes
/etc/rc.d/init.d/httpd restart, status
/etc/rc.d/init.d/sendmail restart, status
/etc/rc.d/init.d/named restart, status     or rndc reload or ndc reload
(depends on version) also directory structure may vary by distro

GREP COMMANDS grep - l word * to list files that contain a certain word
grep - il word * the same, but case insensitive.
ps -ax | grep dhcpd to check if dhcp is functional
ps ax | grep named check if named is running

SEARCH METHODS
find . -type f -exec grep -l 192.168.100.3 {} \;     to check the subnet of the system locate '*.gif' '*.jpg' '*.png' | grep ball     searches for files with 'ball' in file name locate '*' > fileslist.txt &
Ssearch of files and stores the list in the file 'fileslist.txt' of the directory that you initiate the search.
The & initiates a background.

MISC COMMANDS
du -sm $(find $1 -type d -maxdepth 1 -xdev) | sort -g     Directory Size Lister/Sorter
find $1 -type d | xargs du -sm | sort -g     All dir sizes

PROCEDURE FOR COPYING DOS FILES & SETUP TO LINUX
cd /
doscp A:setup /setup
chmod +x /setup
./setup

PROCEDURE FOR MAKING A FLOPPY BOOT DISK
mkbootdisk /dev/fd0 version# of your distro make a backup boot disk
mkbootdisk --device /dev/fd0 2.4.21-0.13mdk to make a boot floppy or from dos
\dosutils\rawrite.exe -F images\cdrom.img -d A

PROCEDURE TO FORMAT A FLOPPY DISK
dd if=boot.img of=/dev/fd0 bs=1440k format diskette with linux boot.

CHECK DISK ON LINUX
fsck -AafC check disk - note: /hdaX unmounted before use.
e2fsck another command name, see man.
To force a check disk, you can do it through the shutdown command or by doing the following:
As root, cd / then touch /forcefsck and then reboot. This will start the check on all /hd devices upon the next reboot.
If it displays a fix error, basically you can either allow it to fix it or not.

NOTES - WARNINGS:

As always, you should have created a backup of important system files at least once to avoid beginning from scratch once your system is installed.  Many people on the net will tell you not to work using the root login.   One thing for sure is that I have made mistakes but without them I could not have learned as much as I have.   If you are terrified, then of course, work under the login name that you set up and use su with the root password to do your work.   If you aren't afraid to make mistakes, after all one can always re-install before getting into the heavy duty stuff that requires backups, then do it while you are learning rather than if you are going 24/7/365 online.
One thing for sure, most people make their biggest mistakes in dos, windows, or linux using commands like delete or changing attributes or moving a file and erroneously having the operation work on either one directory or the entire system.   It can happen to the best of us.

I have indicated some of the commands that should be handled carefully by marking them in red.

During my own experiments with linux, I have made changes to many of the operating system files and am happy to say that I have had only one crash during that time which I fixed by simply reverting the changed file to it's previous state.

LINUX SYSTEM COMMANDS:
You may wonder why do I need to know these commands, the answer is that if you are using the gui or x-windows of a linux system then you probably will not need to know most of the following but if you want to know how things are really working then this list is probably the majority of the commands that you want to learn more about.
Be aware that the effects of these commands will occur in the directory that you are in unless you specify directory references.

passwd assign or change user password
useradd or adduser add a new user, can also use linuxconf
su or sudo issue commands as root, requires pswd
date -s to set system date/time
ln a program linker
gunzip -c filename*.tar.gz | tar -xfv - file compressor/decompressor
tar -xf or -xvzf filename file compressor/decompressor
grep text search
man help file reader
mount, umount devices access, eg. mount /cdrom
mkdir to make a directory
cd to change directory
df -k disk info & volumes
dd command A very powerful command to perform backups and disk cloning, see man dd for further information
ls -l to list directory
ln -s /dir/filename shortcut_name creates a symbolic link to a file as a shortcut in another directory
touch filename to manually create a 0 byte file
cp - i copy
mv rename or move files/directories
rm - i to delete
chmod +x filename changes file to batch, only embed shell commands
chmod +/-rwx filename changes permissions of files
chown owner group change owner and/or group of file system areas
set displays o/s parameters like path in dos
top system activity info
vmstat to check CPU usage
nice to check PROCess priority
renice to change process priority
ps ax view progs running in memory
ps -x displays processes
history keyboard history
cat /proc/cpuinfo for various system information
/proc/pci "
/proc/dma "
/proc/interrupts "
procinfo "
free memory info & usage
pstree to produce a process list
which program_name displays info about program directories
topcx filename converts file to pcx
tr -d '\015' convert dos batch to unix by removing "returns" CR
tail -n 400 /var/log/messages | less -N read the last 400 messages in sys log
updatedb update file locate index table
if an error is produced, try touch /var/lib/slocate/slocate.db and then updatedb again.
locate file/dir "phrase" search for files
find file/dir search for files & directories
w displays all logged in users on local system
who displays virtual console users
whoami need I say…
chkconfig - - list to see the run levels of the system process
kbdconfig use to configure keyboard
setserial -h to check or set serial port parameters

note: see /etc/info-dir for additional commands and notes
MAN command_name parameters.

MOUNTING OTHER VOLUMES
DOS mount -t msdos /dev/hda /dos
CDROM mount /dev/cdrom /cdrom
FLOPPY mount /dev/fd0 /floppy
ZIP mount /dev/zip /zip    To unmount umount /…./…..

ALIASES FOR DOS and other COMMANDS
Embed in .bash_profile in root and/or user directories for ease of calling.
These are basically shortcuts like batch commands.
See bash_profile for other aliases added.

APACHE PASSWORD FILE SETUP
htpasswd -c * .htpasswd-users username
Use -c to initially create passwd file name

Htpasswd * .htpasswd-users username
To add users to the file.     * = to indicate directory locations

SSH
ssh-keygen use to initiate ssh for security certificate creation.
This will allow you to test https:// web pages.



Previous page   Linux   Next page
 
Copyright © 2008. All Rights Reserved.   Designs