Unix Commands Flashcards
To familiarize those with some basic Unix shell commands. Credit goes to http://freeengineer.org/learnUNIXin10minutes.html for the list of Unix command I made the flash cards from.
ls
list directory contents
cd
change directory
mkdir
make directory
cp [file1] [file2]
copys a file
mv [file1] [file2]
move or rename a file
/
root directory
/usr
usr directory
chmod 755 file
Changes the permissions of file to be rwx for the owner, and rx for the group and the world. (7 = rwx = 111 binary. 5 = r-x = 101 binary)
ls -a
List all files in current directory including hidden files
ls -l
list a directory in long ( detailed ) format
cat filename
Dump a file to the screen in ascii.
echo $SHELL
Denotes what shell you are using.
export PROJECTS=/usr/local/projects
Defines the environment variable PROJECTS with the value /usr/local/projects.
cd $PROJECTS
Changes your present working directory to the value of the environment variable PROJECTS
echo $PROJECTS
Prints out the value of PROJECTS, or /usr/local/projects
find . -name aaa.txt
Finds all the files named aaa.txt in the Current directory or any subdirectory tree.
find / -name vimrc
Find all the files named ‘vimrc’ anywhere on the system.
find search_path -name filename
Find command
chown bruce file
Makes user bruce owner of file
chown -R bruce dir
Makes user bruce owner of directory and everything in its directory tree.
chgrp user file
Makes file belong to the group user.
~
Home directory
rm file1 [file2 …]
Remove or delete a file
rm -r dir1 [dir2…]
recursivly remove a directory and its contents
rmdir dir1 [dir2…]
remove an empty directory
more filename
Progressively dump a file to the screen: ENTER = one line down, SPACEBAR = page down, q=quit
head filename
Show the first few lines of a file.
head -n filename
Show the first n lines of a file
tail filename
Show the last few lines of a file.
tail -n filename
Show the last n lines of a file.
Show the last n lines of a file.
Show the last n lines of a file.
ls -ld *
List all the file and directory names in the current directory using long format. Without the “d” option, ls would list the contents of any sub-directory of the current. With the “d” option, ls just lists them like regular files.
touch
Changes the date/time stamp of the file filename to the current time. Creates an empty file if the file does not exist. You can change the stamp to any date using
users
List users currently logged in
killall
Kill processes by name
ps
process status
tar
tape archive
tar xv
Extracts (x) files from the default tape drive while listing (v = verbose) the file names to the screen.
ping
Test a network connection
who
Print all usernames currently logged in
whoami
Print the current user id and name (`id -un’)
wget
Retrieve web pages or files via HTTP, HTTPS or FTP