BASIC COMMANDS
   
mkdir - make directories

mkdir [OPTION] DIRECTORY

Options

Create the DIRECTORY(ies), if they do not already exist.

 Mandatory arguments to long options are mandatory for short options too.

 -m, mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask

 -p, parents no error if existing, make parent directories as needed

 -v, verbose print a message for each created directory

 -help display this help and exit

 -version output version information and exit

cd - change directories

Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below.

mv- change the name of a directory

Type mv followed by the current name of a directory and the new name of the directory.

 Ex: mv testdir newnamedir 

pwd - print working directory

will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page

 rmdir - Remove an existing directory 





chown - change file owner and group

chown [OPTION] OWNER[:[GROUP]] FILE

chown [OPTION] :GROUP FILE

chown [OPTION] --reference=RFILE FILE

Options

Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference, change the owner and group of each FILE to those of RFILE.

 -c, changes like verbose but report only when a change is made

 -dereference affect the referent of each symbolic link, rather than the symbolic link itself

 -h, no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink)

 -from=CURRENT_OWNER:CURRENT_GROUP

  change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute.

-no-preserve-root do not treat `/' specially (the default)

-preserve-root fail to operate recursively on `/' 

-f, -silent, -quiet suppress most error messages

-reference=RFILE use RFILE's owner and group rather than the specifying OWNER:GROUP values

-R, -recursive operate on files and directories recursively

-v, -verbose output a diagnostic for every file processed

The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect.





-L traverse every symbolic link to a directory encountered
-P do not traverse any symbolic links (default)

chmod - change file access permissions

chmod [-r] permissions filenames

 r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format.filenames File or directory that you are associating the rights with Permissions

u - User who owns the file.

g - Group that owns the file.

o - Other.

a - All.

r - Read the file.

w - Write or edit the file.

x - Execute or run the file as a program.

Numeric Permissions:

CHMOD can also to attributed by using Numeric Permissions:

400 read by owner

040 read by group

004 read by anybody (other)

200 write by owner

020 write by group

002 write by anybody





010 execute by group

001 execute by anybody

ls - Short listing of directory contents 

-a list hidden files

-d list the name of the current directory

-F show directories with a trailing '/'

  executable files with a trailing '*'

-g show group ownership of file in long listing

-i print the inode number of each file

-l long listing giving details about files and directories

-R list all subdirectories encountered

-t sort by time modified instead of name

cp - Copy files 

cp myfile yourfile 

Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists. 

cp -i myfile yourfile

With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten. 

cp -i /data/myfile 

Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file. 

cp -dpr srcdir destdir 



Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir

ln - Creates a symbolic link to a file.

ln -s test symlink

Creates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test. 

locate - A fast database driven file locator.

slocate -u 

This command builds the slocate database. It will take several minutes to complete this command.This command must be used before searching for files, however cron runs this command periodically on most systems.locate whereis Lists all files whose names contain the string "whereis". directory. 

more - Allows file contents or piped output to be sent to the screen one page at a time

less - Opposite of the more command

cat - Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.

whereis - Report all known instances of a command

wc - Print byte, word, and line counts 
bg 

bg jobs Places the current job (or, by using the alternative form, the specified jobs) in the background, suspending its execution so that a new user prompt appears immediately. Use the jobs command to discover the identities of background jobs.

cal month year - Prints a calendar for the specified month of the specified year.

cat files - Prints the contents of the specified files.

clear - Clears the terminal screen.


cmp file1 file2 - Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs.

diff file1 file2 - Compares two files, reporting all discrepancies. Similar to the cmp command, though the output format differs.

dmesg - Prints the messages resulting from the most recent system boot.

fg 

fg jobs - Brings the current job (or the specified jobs) to the foreground.

file files - Determines and prints a description of the type of each specified file.

find path -name pattern -print 

Searches the specified path for files with names matching the specified pattern (usually enclosed in single quotes) and prints their names. The find command has many other arguments and functions; see the online documentation.

finger users - Prints descriptions of the specified users.

free - Displays the amount of used and free system memory.

ftp hostname

Opens an FTP connection to the specified host, allowing files to be transferred. The FTP program provides subcommands for accomplishing file transfers; see the online documentation.

head files - Prints the first several lines of each specified file.

ispell files - Checks the spelling of the contents of the specified files.

kill process_ids 

kill - signal process_ids 

kill -l 

Kills the specified processes, sends the specified processes the specified signal (given as a number or name), or prints a list of available signals.

killall program 


killall - signal program 

Kills all processes that are instances of the specified program or sends the specified signal to all processes that are instances of the specified program.

mail - Launches a simple mail client that permits sending and receiving email messages.



man title 

man section title - Prints the specified man page.

ping host - Sends an echo request via TCP/IP to the specified host. A response confirms that the host is operational.

reboot - Reboots the system (requires root privileges).

shutdown -r minutes 

Shuts down the system after the specified number of minutes elapses (requires root privileges). The -r option causes the system to be rebooted once it has shut down.

sleep time - Causes the command interpreter to pause for the specified number of seconds.

sort files - Sorts the specified files. The command has many useful arguments; see the online documentation.

split file - Splits a file into several smaller files. The command has many arguments; see the online documentation

sync - Completes all pending input/output operations (requires root privileges).

telnet host - Opens a login session on the specified host.

top - Prints a display of system processes that's continually updated until the user presses the q key.

w - Prints the current system users.

wall - Prints a message to each user except those who've disabled message reception. 


Type Ctrl-D to end the message.
[Alt][Ctrl][F1] - switch to the first virtual text console 

[Alt][Ctrl][Fn] - switch to the nth virtual text console. Typically, there are six on a Linux PC system. 

[Alt][Ctrl][F7] - switch to the first GUI console, if there is one running. If the graphical console freezes, one can switch to a nongraphical console, kill the process that is giving problems, and switch back to the graphical console using this shortcut. 

[ArrowUp] - scroll through the command history (in bash) 

[Shift][PageUp] - scroll terminal output up. This also works at the login prompt, so you can scroll through your boot messages. 

[Shift][PageDown] - scroll terminal output down 

[Ctrl][Alt][+] - switch to next X server resolution (if the server is set up for more than one resolution) 

[Ctrl][Alt][-] - change to previous X server resolution 

[Ctrl][Alt][BkSpc] - kill the current X server. Used when normal exit is not possible. 

[Ctrl][Alt][Del] - shut down the system and reboot 

[Ctrl]c - kill the current process 

[Ctrl]d - logout from the current terminal 

[Ctrl]s - stop transfer to current terminal 

[Ctrl]q - resume transfer to current terminal. This should be tried if the terminal stops responding. 

[Ctrl]z - send current process to the background 

reset - restore a terminal to its default settings 

3. Dot Files
There is some redundancy across these programs. For example, the look and behavior of emacs can be customized by using the emacs file, but also by adding the appropriate modifications to the .X defaults file. Default versions of these files are often installed in users' home directories when the software packages that use them are installed. If a program doesn't find its configuration file in the user's home directory, it will often fall 

back on a system-wide default configuration file installed in one of the subdirectories that the package lives in. 


.bash_logout - file executed by bash shell on logout 

.bash_profile - initialization of bash shell run only on login. Bash looks first for a .bash_profile file when started as a login shell or with the -login option. If it does not find .bash_profile, it looks for .bash_login. If it doesn't find that, it looks for .profile. System-wide functions and aliases go in /etc/bashrc and default environment variables go in /etc/profile. 

.bashrc - initialization command run when bash shell starts up as a non-login shell 

.login - initialization file when user logs in 

.logout - commands run when user logs out 


4. Useful Files

/boot/vmlinuz - the typical location and name of the Linux kernel. In the Slackware distribution, the kernel is located at /vmlinuz. 

/dev/hda - first IDE hard drive 

/dev/hdc - on many machines, the IDE cdrom drive. Most often, there is a symbolic link called /dev/cdrom which is just a link to the true cdrom driver file. 

/dev/null - used when you want to send output into oblivion 

/etc/aliases - file containing aliases used by sendmail and other MTAs (mail transport agents). After updating this file, it is necessary to run the newaliases utility for the changes to be passed to sendmail. 

/etc/bashrc - system-wide default functions and aliases for the bash shell 

/etc/crontab - shell script to run different commands periodically (hourly, daily, weekly, monthly, etc.) 

/etc/DIR_COLORS - used to store colors for different file types when using ls command. The dircolors command uses this file when there is not a .dir_colors file in the user's home directory. Used in conjunction with the eval command (see below). 




/etc/exports - specifies hosts to which file systems can be exported using NFS. Man exports contains information on how to set up this file for remote users. 

/etc/fstab - contains information on partitions and filesystems used by system to mount different partitions and devices on the directory tree 

/etc/HOSTNAME - stores the name of the host computer 

/etc/hosts - contains a list of host names and absolute IP addresses. 

/etc/hosts.allow - hosts allowed (by the tcpd daemon) to access Internet services 

/etc/hosts.deny - hosts forbidden (by the tcpd daemon) to access Internet services 

/etc/group - similar to /etc/passwd but for groups 

/etc/inittab - runs different programs and processes on startup. This is typically the program which is responsible for, among other things, setting the default runlevel, running the rc.sysinit script contained in /etc/rc.d, setting up virtual login terminals, bringing down the system in an orderly fashion in response to [Ctrl][Alt][Del], running the rc script in /etc/rc.d, and running xdm for a graphical login prompt (only if the default runlevel is set for a graphical login). 

/etc/mtab - shows currently mounted devices and partitions and their status 

/etc/passwd - contains passwords and other information concerning users who are registered to use the system. For obvious security reasons, this is readable only by root. It can be modified by root directly, but it is preferable to use a configuration utility such as passwd to make the changes. A corrupt /etc/passwd file can easily render a Linux box unusable. 

/etc/profile - sets system-wide defaults for bash shell. It is this file in Slackware that sets up the DIR_COLORS environment variable for the color ls command. Also sets up other system-wide environment variables. 

/etc/resolv.conf - contains a list of domain name servers used by the local machine 

/etc/securetty - contains a list of terminals on which root can login. For security reasons, this should not include dialup terminals. 

/proc/interrupts - prints interrupts currently in use 




5 .Important Directories
Different distributions have different directory structures, despite attempts at standardization such as the Linux File system Hierarchy Standard (FHS) organization. 

/bin - essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode 

/boot - files used during booting and possibly the kernel itself are stored here 

/dev - contains device files for various devices on system 

/etc - files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc. 

/home - home directories of individual users 

/lib - standard shared library files 

/lib/modules - modular device driver files, most with .o extensions 

/mnt - typical mount point for many user-mountable devices such as floppy drives, cd-rom readers, etc. Each device is mounted on a subdirectory of /mnt. 

/proc - virtual file system that provides a number of system statistics 

/root - home directory for root 

/sbin - location of binaries used for system administration, configuration, and monitoring 

/tmp - directory specifically designed for programs and users to store temporary files. 

/usr - directory containing a number of subdirectory with programs, libraries, documentation, etc. 

/usr/bin - contains most user commands. The /bin directory is generally located on the same disk partition as /, which is mounted in read-only mode during the boot process. Other filesystems are only mounted at a later stage during startup, so putting binaries essential for boot here is not a good idea. 

/usr/include - standard location of include files used in C programs such as stdio.h 

/usr/info - primary location of the GNU info system files 

/usr/lib - standard library files such as libc.a. Searched by the linker when programs are compiled. 

/var - administrative files such as log files, used by various utilities 

/var/log/scripts - package installation scripts in Slackware are stored here. You can inspect these scripts to see what special features are included in individual packages. 

/var/spool - temporary storage for files being printed, mail that has not yet been picked up, etc. 

7. Important Daemons and Startup Services

autofs - control the operation of automount daemons, used to mount and unmount devices on demand 

crond - automatic task scheduler. Manages the execution of tasks that are executed at regular but infrequent intervals, such as rotating log files, cleaning up /tmp directories, etc. 

cups - daemon for print services under the Common Unix Printer System, a replacement for lpd 

dhcpd - implements the Dynamic Host Configuration Protocol (DHCP) and the Internet Bootstrap Protocol (BOOTP). Used to lease out IP addresses to remote machines. 

ftpd - ftp server daemon 

httpd - the Apache webserver hypertext transfer protocol daemon 

netfs - network filesystem mounter. Used for mounting nfs, smb and ncp shares on boot. 

network -activates all network interfaces at boot time by calling scripts in /etc/sysconfig/network-scripts 

nfsd - used for exporting nfs shares when requested by remote systems 

nfslock - starts and stops nfs file locking service 

portmap - needed for Remote Procedure Calls 

sendmail - mail transfer agent. This is the agent that comes with Red Hat. Others, such as smtpd, are not included. 

smb - needed for running SAMBA 

squid - web page proxy server daemon 


smtpd - Simple Mail Transfer Protocol, designed for the exchange of electronic mail messages. Several daemons that support SMTP are available, including sendmail, smtpd, rsmtpd, qmail, zmail, etc. 

telnetd - telnet server daemon 

usb - daemon for devices on Universal Serial Bus 

xfs - X font server 

xinetd - more modern replacement for inetd. It apparently allows for similar kinds of access filters to the ones used by tcpd in conjunction with inetd. xinetd replaces inetd as the default network services daemon in Red Hat 7.0. 

ypbind - NIS binder. Needed if computer is part of Network Information Service domain. 






 
Make a Free Website with Yola.