Navigation and search related commands
ls - List files in a directory
ls -f - Short directory listing
ls -l - Detailed directory list shows ownership, properties and size
ls -a - List all files in the working directory including hidden files
cd <directory or path> - Change or move to destination directory or path ie.. cd /home
cd .. - This will take you one level below the current directory
whereis <filename> - Find the directory where a file or module is located on the server
locate <filename> - Locate a file anywhere on the server
pwd - Outputs the path of the current working directory
man <command> - Provides a manual for the requested command or program
apropos <keyword> - Finds documentation
grep -R <string to search for> * - Provides a recursive string match in all files within the working directory
Some things to remember when working in a Unix like environment
since everything works from a command line. Most commands are stack-able by using a pipe
dilemma | which works similar to a line break or carriage return. When using the recursive
option -R you should always use extreme caution. By using the recursive option when deleting
files while using wild-card strings * you can wipe the entire hard drive. So it is very important to
understand how to use commands properly to prevent serious data loss.
Working with files and folders
cp <filename> <newfilename> - Copy a file which can be useful to create a backup files
cp -R <path/folder> <path/destination-folder> - Copy a directory recursively to the destination
mv <filename> <newname> - Rename a file or directory
mv -R <path/folder> <path/destination-folder> - Move directory recursively to the destination
mkdir - Creates a new directory
rm <filename> - Delete a file (this cannot be undone)
rm -rf <directory> - Delete all files within a directory recursively
tar cvzpf <file.archive.gz> <filename> - Creates a Gzip archive of the specified filename
tar -zxvf <file.tar.gz> - Extracts the specified Tar/Gzip archive to the working directory
rpm -Uhv <file.rpm> - Install RPM File (most often used to update modules)
chmod <options> <filename> - Set read/write/execute permissions on a file or folder
chown <user>:<group> <filename> - Set specified file ownership rights
chown -R <user>:<group> * - Set recursive working directory ownership
Working with NCFTP
ncftp - Internet file transfer program (must be installed to use)
open -u <user> -p <password> <remote-address> - Make connection to an external FTP server
ls - List remote working directory
lls - List local working directory
cd <directoy/path> - Browse remote system
lcd <directoy/path> - Browse local system
get -R <directoy/path> - Get entire directory recursively (permissions intact)
get -r <filename> - Get file specified
get -TR <directoy/path> - Get each file in directory without compression
screen -r - Attach to screen (attaches screen to the working process)
ctrl -a-d - Detach from screen (transfer process will run in the background)
System and environment information
date - Gives current date
daytime - Displays time in words
time - Displays a 24-hour clock
w - Shows load averages, uptime and users currently logged in
netstat -an - Shows active UNIX domain sockets
ps -aux - Lists all current running processes
ps -aux | grep <name> - Lists all process of damon name such as Apache
df -h - Displays disk usage by volume
du | sort -n - Lists and sorts directories by usage
quota -v username - Shows usage of user quota
More commands will be added over time. If you have specific questions about these
or other commands more documentation can be found at
www.freebsd.org to guide you.