Beruflich Dokumente
Kultur Dokumente
Multi-user - Support more than one user session, simultaneously, on the same system, at
a time.
Supports virtual memory, programs larger than the physical RAM of the system, can be
executed.
Supports hierarchical file system to hold user data organised in the form of directories
and files.
Identifies a user with a userid and groupid and allows access permissions to resources to
be specified using these ids.
Supports a command language selectable on a per user basis. (Example: csh, sh, and ksh)
Supports a large number of tools, libraries and utilities to aid software development.
Bc
Calculator.
Cal
Calendar
Cd
Change directory.
Chdir
Change directory.
Chmod
Change the permission of a file.
Chown
Change the ownership of a file.
Clear
Clears screen.
cmp
Compare files.
Cls
Alias often used to clear a screen.
copy
Copy files.
Cp
Copy files.
date
Tells you the date and time in Unix.
echo
Displays text after echo to the terminal.
Exit
Exit from a program, shell or log you out of a Unix network.
gunzip
Expand compressed files.
Gzip
Compress files.
login
Signs into a new system.
logname
Returns users login name.
logout
Logs out of a system.
mailx
Mail interactive message processing system.
mail
One of the ways that allows you to read/send E-Mail.
man
Display a manual of a command.
mkdir
Create a directory.
More
Displays text one screen at a time.
mount
Creates a file systems and remote resources.
netstat
Shows network status.
passwd
Allows you to change your password.
pwd
Print the current working directory.
Rm
Deletes a file without confirmation (by default).
rmdir
Deletes a directory.
sendmail
Sends mail over the Internet
shutdown
Turn off the computer immediately or at a specified time.
Tar
Create tape archives and add or extract files.
Tee
Tput
Initialize a terminal or query terminfo database.
Tty
Print the file name of the terminal connected to standard input.
uname
Print name of current system.
unmount
Disconnects a file systems and remote resources.
unzip
List, test and extract compressed files in a ZIP archive.
Vi
Screen-oriented (visual) display editor based on ex.
whoami
Print effective userid.
whois
Internet user name directory service.
Zcat
Zip
Compress files.
Compression and file packaging utility.
Slowly adjust the time by sss.fff seconds (fff represents fractions of a second). This
adjustment can be positive or negative. The system's clock will be sped up or slowed down
until it has drifted by the number of seconds specified. Only the super-user may adjust the
time.
-u
Display (or set) the date in Greenwich Mean Time (GMT-universal time), bypassing the
normal conversion to (or from) local time.
-s datestr
Sets the time and date to the value specfied in the datestr. The datestr may contain the
month names, timezones, 'am', 'pm', etc. See examples for an example of how the date and
time can be set.
Examples
date
List the date and time of the server. Below is an example of the output.
Thu Feb 8 16:47:32 MST 2001
date -s "11/20/2003 12:48:00"
Set the date to the date and time shown.
date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'
Would list the time and date in the below format.
DATE: 02/08/01
TIME:16:44:55
cal
Calendar for the month and the year.
Syntax
cal [month] [year]
month
Specifies the month for you want the calendar to be displayed. Must be the
numeric representation of the month. For example: January is 1 and December
is 12.
Year
Examples
cal
Give you the calendar for this month.
cal 12 2000
Give you the calendar for December of 2000.
echo
Echo's to the screen what you type after echo. Echo is useful for producing diagnostics in
command files, for sending known data into a pipe, and for displaying the contents of
environment variables.
Syntax
echo [-n] text
-n
On BSD and some variants derived from BSD does not begin a new line after the
echoed text.
Text
Examples
echo Hello world
The above example would return "Hello world" to the console
echo * | wc
The above example would list a count of all the files and directories in the current directory.
printf
Write formatted output.
Syntax
printf format [ argument]
format
argument
Examples
printf "hello"
Returns hello to the screen.
bc
Calculator.
Syntax
bc [-c] [-l] [file]
-c
Compile only. The output is dc commands that are sent to the standard output.
-l
Define the math functions and initialize scale to 20, instead of the default zero.
file
Name of the file that contains the bc commands to be calculated this is not a necessary
command.
Usage
L
A letter a-z
Statement
/* and /*
Comment
sqrt ( E )
Square root
quit
Available Operators
+-*/%^
(% is remainder; ^ is power)
++ -- (prefix and postfix; apply to names)
== <= >= != < > = =+ =- =* =/ =% =^
Examples
bc cal.txt
Would result in 3, see below notes.
Within the cal.txt file you could have a simple statement such as the example shown below.
/* Add the value 1+2 /*
1+2
quit
When running the above command you will receive the results of the cal.txt file. Which in this
case would be 3.
mailx
Mail interactive message processing system.
Syntax
mailx [-B] [-d] [-e] [-F] [-H] [-i] [-I] [-n] [-N] [-U] [-R] [-t] [-v] [-V] [-~] [-b bcc] [-c cc] [-h
number][ -f [file | +folder ] ] [ -T file ] [ -u user ]
-B
-d
-e
Test for the presence of mail. mailx prints nothing and exits with a successful return code if
there is mail to read.
-F
Record the message in a file named after the first recipient. Overrides the record variable, if
set.
-H
-i
Ignore interrupts.
-I
Include the newsgroup and article-id header lines when printing mail messages. This option
requires the -f option to be specified.
-m
-n
-N
-U
-R
-t
Scan the input for To:, Cc:, and Bcc: fields. Any recipients on the command line will be
ignored.
-v
-V
-~
Interpret tilde escapes in the input even if not reading from a tty.
-b bcc
Set the blind carbon copy list to bcc. bcc should be enclosed in quotes if it contains more
than one name.
-c cc
Set the carbon copy list to cc. cc should be enclosed in quotes if it contains more than one
name.
-h number
The number of network "hops" made so far. This is provided for network software to avoid
infinite delivery loops. This option and its argument are passed to the delivery program.
-r address
Use address as the return address when invoking the delivery program. All tilde commands
are disabled. This option and its argument is passed to the delivery program.
-s subject
Set the Subject header field to subject. subject should be enclosed in quotes if it contains
embedded white space.
recipient
-f [file]
Read messages from file instead of mailbox. If no file is specified, the mbox is used.
-f [+folder]
Use the file folder in the folder directory (same as the fold er command). The name of this
directory is listed in the folder variable.
-T file
Message-id and article-id header lines are recorded in file after the message is read. This
option also sets the -I option.
-u user
Read user's mailbox. This is only effective if user's mailbox is not read protected.
Examples
mailx sarlesh@sarlesh.com
Start a new mail message to be sent to Sarlesh at domain sarlesh.com
passwd
Allows you to change your password.
Examples
passwd - entering just passwd would allow you to change the password. After entering passwd
you will receive the following three prompts:
Current Password:
New Password:
Confirm New Password:
Each of these prompts must be entered and entered correctly for the password to be successfully
changed.
passwd newperson
If you have just setup an account using the useradd command you would then type a command
similar to the above command to set the password for the "newperson" account. Only root users
have the ability to set passwords for other accounts.
who
Displays who is on the system.
Examples
who
The general format for output is: name [state] line time [idle] [pid] [comment] [exit]
where: name user's login name. state capability of writing to the terminal. line name of the line
found in /dev. time time since user's login. idle time elapsed since the user's last activity. pid
user's process id. comment comment line in inittab(4).
Below is an example of what this may look like
chope
pts/0
Apr 23 10:43
(shell.sarlesh.com)
mrhope
pts/1
May 6 18:19
(shell.sarlesh.com)
whoami
Print effective userid.
Syntax
whoami
Examples
whoami
Would display the name of the current userid. For example, may list root if you're logged in as
root.
pwd
Short for print working directory the pwd command displays the name of the current working
directory.
Syntax
pwd
Examples
pwd
Typing pwd at the prompt would give you something similar to:
/home/computerhope/public_html
Users who are familiar with MS-DOS or the Windows command prompt may type cd alone to
print the working directory. However, typing cd alone in Linux and Unix will return you to the
home directory.
cd
Changes the directory.
Syntax
cd [directory]
directory
cd ..
Used to go back one directory on the majority of all Unix shells. It is important that
the space be between the cd and the ..
cd -
When in a Korn shell to get back one directory used to go back one directory.
Examples
cd hope
The above example would go into the hope directory if it exists.
cd ../home/users/computerhope
The above example would go back one directory and then go into the home/users/computerhope
directory.
cd ../../
Next, the above example would go back two directories.
cd
Finally, typing just cd alone will move you into the home directory. If you're familiar with MSDOS and how typing cd alone prints the working directory. Linux and Unix users can print the
working directory by using the pwd command.
mkdir
Short for make directory this command is used to create a new directory.
Syntax
mkdir [option] directory
-m mode
-p
-v
-Z
directory
Examples
mkdir mydir
The above command creates a new directory called mydir.
mkdir -m a=rwx mydir
This next example would use the -m option to not only create the mydir directory but also set the
permissions to all users having read, write, and execute permissions.
rmdir
Deletes a directory.
Syntax
rmdir [OPTION]... DIRECTORY...
--ignorefail-onnon-empty
-p,
--parents
Remove DIRECTORY and its ancestors. E.g., `rmdir -p a/b/c' is similar to `rmdir a/b/c
a/b a'.
-v,
--verbose
--version
Examples
rmdir mydir
Removes the directory mydir
rm -r directory
Remove a directory, even if files existed in that directory.
ls
Lists the contents of a directory.
Syntax
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [u] [-x] [pathnames]
-a
Shows you all files, even files that are hidden (these files begin with a dot.)
-A
List all files including the hidden files. However, does not display the working directory (.)
or the parent directory (..).
-b
-c
Use time of last modification of the i-node (file created, mode changed, and so forth) for
sorting (-t) or printing (-l or -n).
-C
Multi-column output with entries sorted down the columns. Generally this is the default
option.
-d
-f
Force each argument to be interpreted as a directory and list the name found in each slot.
This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries
appear in the directory.
-F
Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>),
executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic
links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals
sign (=).
-g
-i
For each file, print the i-node number in the first column of the report.
-l
Shows you huge amounts of information (permissions, owners, size, and when last
modified.)
-L
If an argument is a symbolic link, list the file or directory the link references rather than the
link itself.
-m
Stream output format; files are listed across the page, separated by commas.
-n
The same as -l, except that the owner's UID and group's GID numbers are printed, rather
than the associated character strings.
-o
-p
-q
Force printing of non-printable characters in file names as the character question mark (?).
-r
-R
-s
-t
-u
Use time of last access instead of last modification for sorting (with the -t option) or printing
(with the -l option).
-x
-1
Directories
Group
Size
Date
Directory or file
drwx------
users
4096
Nov 2 19:51
mail/
drwxr-s---
35
www
32768
Jan 20 22:39
public_html/
-rw-------
users
Nov 25 02:58
test.txt
Below is a brief description of each of the above categories shown when using the ls -l
command.
Permissions - The permissions of the directory or file.
Directories - The amount of links or directories within the directory. The default amount of
directories is going to always be 2 because of the . and .. directories.
Group - The group assigned to the file or directory
Size - Size of the file or directory.
Date - Date of last modification.
Directory of file - The name of the file or file.
ls -laxo
Our favorite ls command, which lists files with permissions, shows hidden files, displays in a
column format, and doesn't show the group.
ls -1 | wc -l
Count how many files and directories are in the current directory. To prevent any confusion, the
above command reads ls <dash><the #1> <pipe> ls <dash><the letter l>. This command uses
the ls command to list files in a bare format and pipes the output into the wc command to count
how many files are listed. When done properly, the terminal should return a single number
indicating how many lines were counted and then return you to the prompt.
Keep in mind that this is also counting the ./ and ../ directories.
ls ~
List the contents of your home directory by adding a tilde after the ls command.
ls /
List the contents of your root directory.
ls ../
List the contents of the parent directory.
ls */
cat
Allows you to look, modify or combine a file.
Syntax
cat filename [-n] [-b] [-u] [-s] [-v]
filename The name of the file or files that you wish to look at or perform tasks on.
-n
-b
Number the lines, as -n, but omit the line numbers from blank lines.
-u
-s
-v
Non-printing characters (with the exception of tabs, new-lines and form-feeds) are
printed visibly. ASCII control characters (octal 000 - 037) are printed as ^n, where n is
the corresponding ASCII character in the range octal 100 - 137 (@, A, B, C, . . ., X, Y,
Z, [, \, ], ^, and _); the DEL character (octal 0177) is printed ^?. Other non-printable
characters are printed as M-x, where x is the ASCII character specified by the low order
seven bits.
-e
A $ character will be printed at the end of each line (prior to the new-line).
-t
cp
Copies files from one location to another.
Syntax
cp [OPTION]... SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... --target-directory=DIRECTORY SOURCE...
-a, --archive
same as dpR
--backup[=CONTROL]
-b
--copy-contents
-d
--no-dereference
-f, --force
-i, --interactive
-H
-l, --link
-L, --dereference
-p
same as --preserve=mode,ownership,timestamps
--parents
-P
same as '--no-dereference'
--remove-destination
--reply={yes,no,query}
--sparse=WHEN
--strip-trailing-slashes
-s, --symbolic-link
-S, --suffix=SUFFIX
copy only when the SOURCE file is newer than the destination file or when
the destination file is missing
-v, --verbose
-x, --one-file-system
Examples
cp file1.txt newdir
Copies the file1.txt in the current directory to the newdir directory.
cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak
Copies the mylog.txt file in the public_html directory into the public_html/backup directory as
mylog.bak. The files are identical however have different names.
cp *.txt newdir
Copy all files ending in .txt into the newdir directory.
cp -r /home/hope/files/* /home/hope/backup
Copies all the files, directories, and subdirectories in the files directory into the backup directory.
yes | cp /home/hope/files/* /home/hope/files2
Copies all the files and subdirectories in files into the files2 directory. If files with the same name
exist or it's prompted to overwrite the file it answers yes.
rm
Deletes a file without confirmation (by default).
Syntax
rm [-f] [-i] [-R] [-r] [filenames | directory]
-f
Remove all files (whether write-protected or not) in a directory without prompting the user.
In a write-protected directory, however, files are never removed (whatever their permissions
are), but no messages are displayed. If the removal of a write-protected directory is
attempted, this option will not suppress an error message.
-i
Interactive. With this option, rm prompts for confirmation before removing any files. It overrides the -f option and remains in effect even if the standard input is not a terminal.
-R
Same as -r option.
-r
Recursively remove directories and subdirectories in the argument list. The directory will be
emptied of files and removed. The user is normally prompted for removal of any writeprotected files which the directory contains. The write-protected files are removed without
prompting, however, if the -f option is used, or if the standard input is not a terminal and the
-i option is not used. Symbolic links that are encountered with this option will not be
traversed. If the removal of a non-empty, write-protected directory is attempted, the utility
will always fail (even if the -f option is used), resulting in an error message.
filenames
Examples
rm myfile.txt
Remove the file myfile.txt without prompting the user.
rm -r directory
Remove a directory, even if files existed in that directory.
Note that if you use rm to remove a file, it is usually possible to recover the contents of that file.
If you want more assurance that the contents are truly unrecoverable, consider using shred.
mv
Renames a file or moves it from one directory to another directory.
Syntax
mv [-f] [-i] oldname newname
-f
mv will move the file(s) without prompting even if it is writing over an existing target.
Note that this is the default if the standard input is not a terminal.
-i
oldname
newname
filename
The name of the file you want to move directory - The directory of were you want the
file to go.
Examples
mv myfile.txt newdirectory/
Moves the file myfile.txt to the directory newdirectory.
mv myfile.txt ../
Moves the file myfile.txt back one directory (if available).
mv computer\ hope.txt computer_hope.txt
Moves (renames) the file "computer hope.txt" to computer_hope.txt. When working with a file
or directory with a space you must escape that space with a backslash or surround the filename
or directory with quotes.
wc
Short for word count, wc displays a count of lines, words, and characters in a file.
Syntax
wc [-c | -m | -C ] [-l] [-w] [ file ... ]
-c
Count bytes.
-m
Count characters.
-C
Same as -m.
-l
Count lines.
-w
Count words delimited by white space characters or new line characters. Delimiting
characters are Extended Unix Code (EUC) characters from any code set defined by
iswspace()
file
Examples
wc myfile.txt
Displays information about the file myfile.txt. Below is an example of the output.
5
13
57 myfile.txt
5 = Lines
13 = Words
57 = Characters
ls -1 | wc -l
Count how many files and directories are in the current directory. To prevent any confusion, the
above command reads ls <dash><the #1> <pipe> ls <dash><the letter l>. This command uses
the ls command to list files in a bare format and pipes the output into the wc command to count
how many files are listed. When done properly, the terminal should return a single number
indicating how many lines were counted and then return you to the prompt.
cmp
Compares two files and tells you what line numbers are different.
Syntax
cmp [-c] [-i N] [-l] [-s] [-v] firstfile secondfile
-c
-i N
-l
Write the byte number (decimal) and the differing bytes (octal) for each difference.
-s
-v
firstfile
secondfile
Examples
cmp file1.txt file2.txt
Compares file1 to file2 and outputs results. Below is example of how these results may look.
file.txt file2.txt differ: char 1011, line 112
comm
Select or reject lines common to two files.
Syntax
comm [-1] [-2] [-3 ] file1 file2
-1
-2
-3
file1
file2
Examples
comm myfile1.txt myfile2.txt
The above example would compare the two files myfile1.txt and myfile2.txt
Ascii text mode: convert end-of-lines using local conventions. This option is supported
only on some non-Unix systems. For MSDOS, CR LF is converted to LF when
compressing, and LF is converted to CR LF when decompressing.
-c --stdout
--to-stdout
Write output on standard output; keep original files unchanged. If there are several input
files, the output consists of a sequence of independently compressed members. To obtain
better compression, concatenate all input files before compressing them.
-d
Decompress.
--decompre
ss
--uncompre
ss
-f --force
Force compression or decompression even if the file has multiple links or the
corresponding file already exists, or if the compressed data is read from or written to a
terminal. If the input data is not in a format recognized by gzip, and if the option --stdout is
also given, copy the input data without change to the standard ouput: let zcat behave as cat.
If -f is not given, and when not running in the background, gzip prompts to verify whether
an existing file should be overwritten.
-h --help
-l --list
zcat file.Z | wc -c
In combination with the --verbose option, the following fields are also displayed:
method: compression method
crc: the 32-bit CRC of the uncompressed data
date & time: time stamp for the uncompressed file
The compression methods currently supported are deflate, compress, lzh (SCO compress
-H) and pack. The
crc is given as ffffffff for a file not in gzip format.
With --name, the uncompressed name, date and time are those stored within the compress
file if present.
With --verbose, the size totals and compression ratio for all files is also displayed, unless
some sizes are unknown. With --quiet, the title and totals lines are not displayed.
-L --license Display the gzip license and quit.
-n --noname
When compressing, do not save the original file name and time stamp by default. (The
original name is always saved if the name had to be truncated.) When decompressing, do
not restore the original file name if present (remove only the gzip suffix from the
compressed file name) and do not restore the original time stamp if present (copy it from
the compressed file). This option is the default when decompressing.
-N --name
When compressing, always save the original file name and time stamp; this is the default.
When decompressing, restore the original file name and time stamp if present. This option
is useful on systems which have a limit on file name length or when the time stamp has
been lost after a file transfer.
-q --quiet
-r
--recursive
Travel the directory structure recursively. If any of the file names specified on the
command line are directories, gzip will descend into the directory and compress all the files
it finds there (or decompress them in the case of gunzip ).
-S .suf
Use suffix .suf instead of .gz. Any suffix can be given, but suffixes other than .z and .gz
--suffix .suf should be avoided to avoid confusion when files are transferred to other systems. A null
suffix forces gunzip to try decompression on all given files regardless of suffix, as in:
gunzip -S "" * (*.* for MSDOS)
Previous versions of gzip used the .z suffix. This was changed to avoid a conflict with pack.
-t --test
-v --verbose Verbose. Display the name and percentage reduction for each file compressed or
decompressed.
-V --version Version. Display the version number and compilation options then quit.
-# --fast
--best
Regulate the speed of compression using the specified digit #, where -1 or --fast indicates
the fastest compression method (less compression) and -9 or --best indicates the slowest
compression method (best compression). The default compression level is -6 (that is, biased
towards high compression at expense of speed).
Examples
gzip myfile
Compresses the file myfile, making it myfile.gz. Note. When doing this the original file will no
longer exist on the drive.
gunzip -f myfile.gz
Uncompress the file myfile.gz and if the uncompressed file(s) already exist force an overwrite.
When doing this the file myfile.gz will no longer be on the drive.
zcat myfile
Uncompress the file myfile.
tar
Create tape archives and add or extract files.
Examples
Note: A ".tar" file is not a compressed files, it is a collection of files within a single file
uncompressed. If the file is a .tar.gz ("tarball") or ".tgz" file it is a collection of files that is
compressed. If you are looking to compress a file you would create the tar file then gzip the file.
Creating a tar file:
tar -cvwf file.tar myfile.txt
In the above example the system would create a tar named file.tar in the directory you currently
are in.Wildcards could also be used in this command, for example: tar -cvwf file.tar *.txt would
compress all txt files in the current directory.
tar -cvwf home.tar home/
In the above example command the system would create a tar file named home.tar in the
directory you currently are in of the home directory.
Extracting the files from a tar file:
tar -xvwf myfile.tar
In the above example command the system would uncompress (untar) the myfile.tar file in the
current directory.
tar -xvwzf myfile.tar.gz
In the above example command the system would uncompress (untar) the myfile.tar.gz file in the
current directory.
Note: There is no "untar" Linux and Unix command.
Creating a tarred file that is compressed with bzip
tar -cjvf test.tbz home/
Adding the j option to the tar command enables tar to compress files and directories using bzip.
In the above example the home directory and all its subdirectories are added to the compressed
test.tbz file.
zip
zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows NT,
Minix, Atari and Macintosh, Amiga and Acorn RISC OS.
It is analogous to a combination of the UNIX commands tar and compress and is compatible
with PKZIP (Phil Katz's ZIP for MSDOS systems).
A companion program (unzip), unpacks zip archives. The zip and unzip programs can work with
archives produced by PKZIP, and PKZIP and PKUNZIP can work with archives produced by
zip. zip version 2.31 is compatible with PKZIP 2.04. Note that PKUNZIP 1.10 cannot extract
files produced by PKZIP 2.04 or zip 2.31. You must use PKUNZIP 2.04g or unzip 5.0p1 (or later
versions) to extract them.
Examples
zip stuff *
Creates the archive stuff.zip (assuming it doesn't already exist) and puts all the current files in the
current directory into it, in the compressed form.
Because of the way the shell does filename substitution, files starting with "." are not included; to
include these as well: zip stuff .* *
zip logfiles file.log file2.log
Next, this command zips the file.log and file2.log into the logfiles.zip archive.
zip -r hope hope
Zip up the entire hope directory as the archive hope.zip.
zip -rm foo foo/tom
Zip the tom subdirectory in foo into the foo.zip archive while removing the files at the same
time. This can be useful if you need to create a zip file but are running low on disk space.
unzip
unzip will list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems.
The default behavior (with no options) is to extract into the current directory (and subdirectories
below it) all files from the specified ZIP archive. A companion program, zip, creates ZIP
archives; both programs are compatible with archives created by PKWAREE'sPKZIP and
PKUNZIP for MS-DOS, but in many cases the program options or default behaviors
differ.PKZIP and PKUNZIP for MS-DOS, but in many cases the program options or default
behaviors differ.
Examples
unzip hope
Unzip the hope.zip archive into the current directory.
chmod
Changes the permission of a file.
Syntax
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
-c, --changes
--no-preserveroot
--preserve-root
-f, --silent,
--quiet
-v, verbose
--help
--version
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:
rw
rw-
r--
hope
123
Feb 03 15:36
file.txt
File
owner
group
everyone else
links
owner
size
mod date
file name
VI Editor
The default editor that comes with the UNIX operating system is called vi (visual editor).
[Alternate editors for UNIX environments include pico and emacs, a product of GNU.]
The UNIX vi editor is a full screen editor and has two modes of operation:
1. Command mode commands which cause action to be taken on the file, and
2. Insert mode in which entered text is inserted into the file.
In the command mode, every character typed is a command that does something to the text file
being edited; a character typed in the command mode may even cause the vi editor to enter the
insert mode. In the insert mode, every character typed is added to the text in the file; pressing
the <Esc> (Escape) key turns off the Insert mode.
While there are a number of vi commands, just a handful of these is usually sufficient for
beginning vi users. To assist such users, this Web page contains a sampling of
basic vi commands. The most basic and useful commands are marked with an asterisk (* or star)
in the tables below. With practice, these commands should become automatic.
NOTE: Both UNIX and vi are case-sensitive. Be sure not to use a capital letter in place of a
lowercase letter; the results will not be what you expect.
Command
Result
vi filename
Two modes in vi editor: insert and command (default is command mode when file is opened)
I
Esc
in command mode
:q
quit file
:q!
:w
:wq
delete character
/string
?string
:g/string/s//string2/g
:line#
:$
:.,$d
:.,.+20d
Creating Files: You can use vi editor to create ordinary files on any Unix system. You
simply need to give following command: $ vi filename Above command would open
a file with the given filename. You would need to press key i to come into edit mode.
Once you are in edit mode you can start writing your content in the file as below:
This is unix file....I created it for the first time..... I'm going to save this content in
this file. Once you are done, do the following steps: Press key esc to come out of
edit mode. Press two keys Shift + ZZ together to come out of the file completely.
Now you would have a file created with filemame in the current directory
Editing Files: You can edit an existing file using vi editor. We would cover this in
detail in a separate tutorial. But in short, you can open existing file as follows: $ vi
filename Once file is opened, you can come in edit mode by pressing key i and then
you can edit file as you like. If you want to move here and there inside a file then
first you need to come out of edit mode by pressing key esc and then you can use
following keys to move inside a file: l key to move to the right side. h key to move
to the left side. k key to move up side in the file. j key to move down side in the
file. So using above keys you can position your cursor where ever you want to edit.
Once you are positioned then you can use i key to come in edit mode. Edit the file,
once you are done press esc and finally two keys Shift + ZZ together to come out of
the file completely.