Unix Commands: Cat Chmod CD CP Date Echo FTP Grep Head Ls LPR Print More Mkdir MV NCFTP FTP
Unix Commands: Cat Chmod CD CP Date Echo FTP Grep Head Ls LPR Print More Mkdir MV NCFTP FTP
Unix Commands: Cat Chmod CD CP Date Echo FTP Grep Head Ls LPR Print More Mkdir MV NCFTP FTP
cat --- for creating and displaying short files(We can use to create, view and
concatenate files)
chmod --- change permissions(This command is used to change the
permissions of a file or directory)
cd --- change directory
cp --- for copying files
date --- display date(Use this command to check the date and time)
echo --- echo argument(The echo command echoes its arguments
ftp --- connect to a remote machine to download or upload files(Use ftp to
connect to a remote machine, then upload or download files)
grep --- search file(Use this command to search for information in a file or
files)
head --- display first part of file
ls --- see what files you have(Use ls to see what files you have. Your files are
kept in something called a directory.)
lpr --- standard print command (see also print )( This is the standard Unix
command for printing a file. It stands for the ancient "line printer)
more --- use to read files(More is a command used to read text files)
mkdir --- create directory(Use this command to create a directory)
mv --- for moving and renaming files(Use this command to change the name
of file and directories)
ncftp --- especially good for downloading files via anonymous ftp.(
Use ncftp for anonymous ftp --- that means you don't have to have a
password.)
print --- custom print command (see also lpr )( This is a moderately intelligent
print command.)
pwd --- find out what directory you are in(Use this command to find out what
directory you are working in.)
rm --- remove a file(Use rm to remove files from your directory.)
rmdir --- remove directory(Use this command to remove a directory)
rsh --- remote shell(Use this command if you want to work on a computer different
from the one you are currently working on. One reason to do this is that the remote
machine might be faster. For example, the command
% rsh solitude
connects you to the machine solitude. This is one of our public workstations and is
fairly fast.)
vi
This command starts the vi text editor. To edit a file named myfile in the current
directory, enter:
vi myfile
Command Example Description
1. grep <str><files> grep "bad word" * Find which files contain a certain
word
2. chmod <opt> chmod 644 *.html Change file permissions read only
<file> chmod 755 file.exe Change file permissions to
executable
7. cal <mo> <yr> cal 9 2000 Print calendar for September 2000
10. mpage <opt> mpage -8 file1 Print 8 pages on a single sheet and send to
<file> | lpr printer (the font will be small!)
9. m-tools (mdir, mcopy, mdir a: DOS commands from UNIX (dir A:)
mdel, mformat, etc. ) mcopy file1 a: Copy file1 to A:
3. alias alias lls="ls -alF" Create new command "lls" for long format
of ls
5. fold fold -s file1 | lpr Fold or break long lines at 60 characters
and send to printer
Top 10 Commands
• Every UNIX user needs these "top 10"
commands
• cat cd date grep ls more mv ps rm who
• And one of these editors:
– vi or emacs
Basics: cat & more
Basics: ls
• ls lists the contents of directories, that is, the
details about files
• ls - short listing (like dir/w)
• ls -l - long listing (dir, explorer list view)
-rw-r--r-- 1 ian wheel 9218 21 Aug 14:49 support.dat
drwxr-xr-x 4 ian admin 136 17 Jan 16:31 talk-others
lrwxr-xr-x 1 ian admin 16 6 Jan 19:31 w -> /shared/w
- Three kinds of things you’ll see: files (”-”),
directories (”d”) and “symlinks” (”l”, like
Aliases or Shortcuts)
ls and Permissions
• UNIX has a more powerful (but complex)
set of permissions than MS-Windows
• Each file or directory has user (owner),
group, and “other” permissions
- Each of which can be r, w or x in any combo
- ls -l shows all this
• The chmod command lets a file’s owner
change its permissions
• If UNIX won’t let you at a file and ls says
it’s there, contact the files’ owner
Basics: grep
• grep finds files that contain a specified
pattern
• grep Mark *.txt
• grep -i mark *.txt # -i = ignore case
• Patterns can be more complex
- a good hour-long discussion
FILE AND RELATED COMMANDS cat file List the contents of file.
More file List the contents of file pausing after each screen
(press Space to continue listing).
pico file Edit file using the Pico full screen editor (user
friendly).