Useful Commands
NetBSD has a bewildering array of commands for you to use. Here is
a quick guide to some of the more commonly used ones. Remember for more
information on a command you can always use read the man pages.
Directory Commands
ls <dir> list all the files in <dir> or the
current directory if no argument is given. Some of the more useful options
include.
ls -a
List all files (files beginning with a dot(.) are
normally
excluded from directory listings).
ls -l
List in long format. This provides extra
information including
size, date and owner.
ls -la
List all files in long format.
mkdir <dirname>
create a directory
named <dirname>.
mkdir -p <dirname1/dirname2>
can be used to create
lengthy
directory trees without the need to create each directory in turn.
rmdir <dirname>
delete an empty
directory.
File Manipulation Commands
mv <file1> <file2>
rename
<file1> to <file2>. If
<file2> exists it will be overwritten. <file1> will be removed
after it has been moved.
cp <file1> <file2>
copy
<file1> to <file2>. If <file2> exists it will be overwritten.
<file1> will not be removed.
cp -r
recursive copy. If <file1> is a directory it's
contents will also be copied.
cp -p
preserve permissions. The owner and execute permissions
of the new file will be the same as the original file.
cp -rp
perform a recursive copy and preserve all the files
permission flags.
rm <file>
delete a file.
rm -r
recursive delete. If the <file> is a directory rm
will also delete all the files and subdirectories it contains.
rm -i
interactive, rm will prompt for confirmation before
deleting each file.
rm -ri
interactive, recursive delete. This can be useful when
you wish to selectively delete certain files within a directory.
Misc
su
switch user.
If su is called with no arguments NetBSD will assume you wish to change to the Super User (root).
If you wish to change to another user you can specify their login name on the command line, i.e.
> su ben
su has one argument, a minus (-). If this is present su will exectue the new users .cshrc file. If no minus is given su will simply change your ID to that of the specified user.
To su to root you must be in the group Wheel. You must supply a password to su to any user unless you are the Super User.