Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
149 views

Linux Fast Guide: Finding Help

This document provides a guide to important Linux commands for beginners. It lists commands for starting and stopping processes, mounting and unmounting filesystems, finding files, moving and copying files, installing software, user administration, and more. It also summarizes key Linux configuration files and their purposes.

Uploaded by

Lotfi Alsouki
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

Linux Fast Guide: Finding Help

This document provides a guide to important Linux commands for beginners. It lists commands for starting and stopping processes, mounting and unmounting filesystems, finding files, moving and copying files, installing software, user administration, and more. It also summarizes key Linux configuration files and their purposes.

Uploaded by

Lotfi Alsouki
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Linux fast guide

Linux commands are still and they will always be very useful
in a Linux system. I will try to list here, for linux beginners,
some of the most important console commands:

finding help:

man "command" manual pages i.e "man halt"


info "command" extended help pages
man -k "command"
whatis "command"
Starting & Stopping
shutdown -h now - Shutdown the system now and do not reboot.

halt - Stop all processes - same as above.

shutdown -r 5 - Shutdown the system in 5 minutes and reboot.

shutdown -r now - Shutdown the system now and reboot.

reboot - Stop all processes and then reboot - as above.


startx - Start the X system.

Accessing & mounting file systems


mount -t iso9660 /dev/cdrom /mnt/cdrom - Mount the device cdrom and call it cdrom
under the /mnt directory.

mount -t msdos /dev/hdd /mnt/ddrive - Mount hard disk “d” as a msdos file system
and call it ddrive under the /mnt directory.

mount -t vfat /dev/hda1 /mnt/cdrive - Mount hard disk “a” as a VFAT file system and
call it cdrive under the /mnt directory.

umount /mnt/cdrom - Unmount the cdrom

Finding files and text within files


find / -name fname - Starting with the root directory, look for the file called fname.

find / -name ”*fname*” - Starting with the root directory, look for the file containing
the string fname

locate missingfilename - Find a file called missingfilename using the locate command
- this assumes you have already used the command updatedb (see next).

updatedb - Create or update the database of files on all file systems attached to the
linux root directory.

which missingfilename - Show the subdirectory containing the executable file called
missingfilename.

grep textstringtofind - Starting with the directory called dir, /dir look for and list all
files containing textstringtofind.

Moving, copying, deleting & viewing files

ls -l - List files in current directory using long format.

ls -F - List files in current directory and indicate the file type.

ls -laC - List all files in current directory in long format and display in columns.

Cd foldername - openfolder

cd /rootfoldername - i.e cd /boot

rm name - Remove a file or directory called name.

rm -rf name - Kill off an entire directory and all that includes files and subdirectories.

cp filename /home/dirname - Copy the file called filename to the /home/dirname


directory.

mv filename /home/dirname - Move the file called filename to the /home/dirname


directory.

cat filetoview - Display the file called filetoview.

man -k keyword - Display man pages containing keyword.

more filetoview - Display the file called filetoview one page at a time, proceed to
next page using the spacebar.
head filetoview - Display the first 10 lines of the file called filetoview.

head -20 filetoview - Display the first 20 lines of the file called filetoview.

tail filetoview - Display the last 10 lines of the file called filetoview.

tail -20 filetoview - Display the last 20 lines of the file called filetoview.

Installing software for Linux

rpm -ihv name.rpm - Install the rpm package called name.

rpm -Uhv name.rpm - Upgrade the rpm package called name.

rpm -e package - Delete the rpm package called package.

rpm -l package - List the files in the package called package.

rpm -ql package - List the files and state the installed version of the package called
package.

rpm -i --force package - Reinstall the rpm package called package having deleted
parts of it (not deleting using rpm -e).

tar -zxvf archive.tar.gz or tar -zxvf archive.tgz - Decompress the files contained in the
zipped and tarred archive called archive

./configure - Execute the script preparing the installed files for compiling.

User Administration
adduser accountname - Create a new user call accountname.

passwd accountname - Give accountname a new password.

su - Log in as superuser from current login.

exit - Stop being superuser and revert to normal user.

Subdirectories of the root directory:

/bin - Common programs, shared by the system, the system administrator and the
users.
/ boot- The startup files and the kernel, vmlinuz. In some recent distributions also
grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the
many different boot−loaders we know today.
/dev- Contains references to all the CPU peripheral hardware, which are represented
as files with special properties.
/etc - Most important system configuration files are in /etc, this directory contains
data similar to those in the Control Panel in Windows
/home- Home directories of the common users.
/initrd- (on some distributions) Information for booting. Do not remove!
/lib- Library files, includes files for all kinds of programs needed by the system and
the users.
/lost+found- Every partition has a lost+found in its upper directory. Files that
were saved during failures are here.
/misc- For miscellaneous purposes.
/mnt- Standard mount point for external file systems, e.g. a CD−ROM or a digital
camera.
/net- Standard mount point for entire remote file systems
/opt- Typically contains extra and third party software.
/proc- A virtual file system containing information about system resources. More
information about the meaning of the files in proc is obtained by entering the
command man proc in a terminal window. The file proc.txt discusses the
virtual file system in detail.
/root- The administrative user's home directory. Mind the difference between /, the
root directory and /root, the home directory of the root user.
/sbin- Programs for use by the system and the system administrator.
/tmp- Temporary space for use by the system, cleaned upon reboot, so don't use this
for saving any work!
/usr- Programs, libraries, documentation etc. for all user−related programs.
/var- Storage for all variable files and temporary files created by users, such as log
files, the mail queue, the print spooler area, space for temporary storage of files
downloaded from the Internet,or to keep an image of a CD before burning it.

In linux u have to know how to use a text editor in the


terminal window at least to modified the configuration
files(they are text files) here we well have to learn about vi
editor (a little about it but enough):

vi textfilename- creating a text file.


Vi textfile – modified the file
inside the vi text editor:
press "i" so u can insert your text
press "Esc" now u can insert your command like;
• n dd will delete n lines starting from the current cursor position.
• n dw will delete n words at the right side of the cursor.
• x will delete the character on which the cursor is positioned
• :n moves to line n of the file.
• :w will save (write) the file
• :q will exit the editor.
• :q! forces the exit when you want to quit a file containing unsaved changes.
• :wq will save and exit
• :w newfile will save the text to newfile.
:wq! overrides read−only permission (if you have the permission to override
permissions, for instance
when you are using the root account.
• /astring will search the string in the file and position the cursor on the first match
below its position.
• / will perform the same search again, moving the cursor to the next match.
• :1, $s/word/anotherword/g will replace word with anotherword throughout
the file.
for quick guide about vi editor try this command vimtutor

I will try to list here some of the configuration files found in a


Linux system, and what they are useful for:

/etc/profile - System wide environment variables for all users.

/etc/aliases - Where the user's name is matched to a nickname for e-mail.

/etc/fstab - List of devices and their associated mount points. Edit this file to add CD-
ROMs, DOS partitions and floppy drives at startup.

/etc/mtab - This changes continuously as the file /proc/mount changes. In other


words, when filesystems are mounted and unmounted, the change is immediately
reflected in this file.

/etc/mtools.conf - Configuration for all the operations (mkdir, copy, format, etc.) on a
DOS-type filesystem.

/etc/motd - Message of the day broadcast to all users at login.


/etc/rc.d/rc.local - Bash script that is executed at the end of the login process. Similar
to autoexec.bat in DOS. You can put your own initialization stuff in here if you don't
want to do the full Sys V style init stuff.

/etc/crontab - Lists commands and times to run them for the cron deamon.

/etc/cron.* - There are 4 directories that automatically execute all scripts within the
directory at intervals of hour, day, week or month.
/etc/group - Similar to /etc/passwd but for groups rather than users.

/etc/gshadow - Used to hold the group password and group administrator password
information for shadow passwords.

/etc/hosts - A list of all known host names and IP addresses on the machine.

/etc/hosts.allow - Man page same as hosts_access. Read by tcpd at least.

/etc/hosts.deny - Man page same as hosts_access. Read by tcpd at least.

/etc/httpd/conf - Paramters for the Apache web server

/etc/inittab - Specifies the run level that the machine should boot into.

/etc/resolv.conf - Defines IP addresses of DNS servers.

/etc/smb.conf - Config file for the SAMBA server. Allows file and print sharing with
Microsoft clients.

/etc/passwd - The user database with fields giving the username, real name, home
directory, encrypted password and other information about each user.

/etc/printcap - A configuration file for printers.

/etc/rc.d/rc0.d - Contains files used to control run level 0. Usually these files are
softlink files.

/etc/rc.d/rc1.d - Contains files to control run level 1. Scripts beginning with an S are
for start, K for kill.

/etc/rc.d/rc.sysinit - Init runs this when it starts.

/etc/sysconfig/clock - Used to configure the system clock to Universal or local time


and set some other clock parameters.

/etc/sysconfig/i18n - Controls the system font settings.

/etc/sysconfig/init - This file is used to set some terminal characteristics and


environment variables.

/etc/sysconfig/keyboard - Used to configure the keyboard.

/etc/sysconfig/network-scripts/ifcfg-interface - Defines a network interface.


/etc/X11/xorg.config - Config file for X11. Here you can setup the mouse, keyboard,
monitor and video card.

/proc/cpuinfo - Information about the processor such as its type, make and
performance.

/proc/devices - A list of devices configured into the currently running kernel.

/proc/dma - Shows which DMA channels are being used at the moment.

/proc/filesystems - Filesystems that are configured into the kernel. The file used to
detect filesystems if the /etc/filesystems does not exist.

/proc/ioports - Shows which I/O ports are in use at the moment.

/proc/interrupts - Shows which interrupts are in use and how many of each there have
been.

/proc/kcore - An image of the physical memory of the system.

/proc/kmsg - Messages output by the kernel. These are also routed to syslog.

/proc/ksyms - Symbol table for the kernel.

/proc/loadavg - The load average of the system.

/proc/meminfo - Information about memory usage, both physical and swap.

/proc/modules - Which kernel modules are currently loaded.

/proc/mounts - Contains information on filesystems currently mounted, similar to


/etc/mtab

/proc/net - Contains status information about network protocols.

/proc/self - A symbolic link to the process directory of the program that is looking at
/proc. When 2 process look at proc, they get different links.

/proc/stat - Various statistics about the system such as the number of page faults since
the system was booted.

/proc/uptime - The time the system has been up.

/proc/version - The kernel version.


How to build the linux kernel :

now u have the kernel do all this in local dirctory ( dirctory with linux file system)
1.gzip -dc linuxkernel-2.x.x-x.gz.tar | tar xvf -
or //here u extracting your kernel
bzip2 -cd dc linuxkernel-2.x.x-x.bz2.tar | tar xvf -
2. "cd liunuxkernel-2.x.x-x/"
3. "make menuconfig" (or xconfig or gconfig in the grafical user interface) do what
ever u want here . //chossing the kernel setting
4. Esc and save your setting
5. "make" //building your kernel it wel take some time
6. "make modules_install" //installing the modules in your kernel
7. stell in the linux kernel folder
8. "cp arch/i386/boot/bzImage /boot/" here u must chosse your arch folder i.e for
amd64 that well be "cp arch/x86_64/boot/bzImage /boot/ " or whatever.//here u
copy your kernel "bzImage" it,s your kernel to the /boot dirctory
9. "cd /boot/"
10."mv bzImage vmlinuz-2.x.x-x" //here u rename your kernel
11."mkinitrd" //u build the kernel initial now for this we
renamed the kernel
12."cd grub/" //now we well configure grub boot loader
13."vi menu1st" // vi is a text editor
14.press i
15.now write thier lines ,those one that describe linux kernel locaion and the initial
location then change the bath for your kernel location(vmlinux-2.x.x-x) and the
initial path (initrd-2.x.x-x )
16.when u finish check what u did and press Esc
17.":wq" //saving the changes that u made in the text file "menust1"
18."reboot"
19.have fun with your kernel .

You might also like