Most
servers accessed through telnet will be
using the unix operating system. This section
contains a sub set of unix commands useful
for navigating the system and managing files. The
command descriptions use the following
format
command
- use
- invocation
with arguments and useful options
Examples
cd
- change directory
- cd
directory
Changes
current directory to a new directory.
- cd
- This
returns you to your home directory.
- cd
..
- This
moves you up one level in the directory
hierarchy.
- cd
work
- This
moves you to the subdirectory work within
the current directory.
- cd
~/mystuff
- This
moves you to a subdirectory mystuff
within your home directory.
- cd
/usr/users/joe/stuff
- This
moves you to a subdirectory stuff in
Joe's home directory..
chmod
- change access permission (mode) of a file
- chmod
mode filename
Changes
the file-access permission for the
specified file(s) to the specified
permission(mode).
There are two ways to change permissions:
through symbolic or numeric form. Numeric form
is described here. A file is assigned a numeric
"mode" that is the sum of all
modes associated with the file. The modes are as
follows:
400 - owner has read permission
200 - owner has write permission
100 - owner has execute permission
040 - group has read permission
020 - group has write permission
010 - group has execute permission
004 - world has read permission
002 - world has write permission
001 - world has execute permission
The lowest possible mode value is 000 - which
means no one can read, write, or execute the
file. The highest possible value is 777 - which
means everyone can read, write and execute
the file.
- chmod
744 notes
- The
owner can read, write and execute notes.
The files specified group and all other
users may only read the file.
ls
- list files
- ls
options directory
Lists
the contents of the specified
directory. If no directory is specified, the
contents of the current directory are listed.
- ls
- Lists
the contents of the current directory.
- ls
-l
- Lists
the contents of the current directory in
long form - shows file-access permissons,
owner, etc.
- ls
-a
- Lists
the contents of the current directory
including hidden ( dot files like .htaccess)
files.
- ls
-al
- Lists
the contents of the current directory in
long form including hidden files.
- ls
-t /user/user/joe
- Lists
the contents of the Joe's directory by
time stamp.
mkdir
- make directory
- mkdir
options directory
Creates
a new directory.
- mkdir
test
- Creates
a new directory called test.
- mkdir
-m 744 work
- Creates
a new directory called work with
permissions set to 744.
perl
- invoke perl
- perl
filename
- perl
testscript.pl
- Invokes
the perl interpreter for the file
testscripts.pl.
- /usr/local/bin/perl
testscript.pl
- Invokes
the perl interpreter located at
/usr/local/bin/perl for the file
testscripts.pl.
pwd
- print working directory
- pwd
Prints
the full path of the current working
directory.
rm
- remove file
- rm
options files
Removes
files, providing you are the owner of
the file or have write permission to the
directory containing the file. This command can
also be used to delete directories.
Note:
Use this command with caution. When a
file is removed, it is really gone. It does not
go to a recycle bin or waste basket.
- rm
test
- Removes
the file named test.
- rm
*
- Removes
all files in the current directory.
- rm
-r stuff
- Removes
a directory named stuff and all it's
contents, including files and subdirectories.
- rm
-i
- Removes
files after verification from user.
tar
- archive/dearchive files
- tar
function options file
Writes
files to an archive or extracts files
from an archive depending on how the command is
configured. Technically tar stands for
tape archiver because originally most archives
were stored to tape. However, tar writes to
and extracts from hard disks and diskettes as
well as tape. The archive referred to by tar
is, in fact, a file itself, similar to a zip
file.
Note that tar is slightly different than other
unix commands because it has two sets of
options - a function option followed by another
set of options. The most often used
functions are:
c - create a new tar archive
x - extract files from within a tar archive
The most commonly used options are:
v - verbose mode
f - specify device (or file) to archive to or
extract from.
- tar
xvf codegame.tar
- Extracts
all of the files in the archive
codegame.tar using verbose mode (prints a
record).
- tar
cf backup.tar /user/users/joe
- Creates
a new archive named backup.tar of all
the files in the directory /user/users/joe.
which
- which file corresponds to a command
- which
command
List
which file corresponds to the specified
command.
- which
perl5
- Displays
the file path to perl5. i.e:
/usr/bin/perl