Skip to content
pccjamie edited this page May 20, 2013 · 4 revisions

Bash Shell Related Stuff!

What is the difference between .bash_profile vs .bashrc?

This was VERY useful: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

man bash site http://linux.die.net/man/1/bash

This was also helpful. http://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/183980#183980

##Terminal Commands

###Terminal

To invoke a command you give the command name. (ls, pwd) Some commands take arguments (cd Desktop)

cat --- Shows the whole file's contents (cat file.txt) By cat-ting the file we print the entire file to the screen. This might be helpful if the file is short, but here it's more trouble than it's worth

head --- Shows first part of file (head file.txt) Using the head command on the file gives us just the first 10 lines of the file.

tail --- Shows last part of file (tail file.txt, tail -f file.txt) Using tail gives us the last 10 lines. You can call tail with 'option f' to have it return the last 10 lines and keep watching the file for any new additions. (Start the server?)

more --- Shows file one page at a time (more file.txt) Using more will let you open the file like cat but will only show you a page at a time. You can progress by using the spacebar and quit using the q key

grep --- search file (grep seaching_for file.txt) grep is great for searching for something in a file

echo --- Shows argument in terminal (echo "Hi!", echo "Off to a file!" >> file.txt) echo echo's a file to the terminal. One cool thing you can do with it is shovel the echo argument into a file like this: !point touch --- Creates a file if it doesn’t exist, or updates the time stamp (touch file.txt)

More about your world

pwd --- Shows present directory (pwd) ls --- Shows your files in a directory (ls, ls -al, ls Desktop)

Moving and shaking cd --- Change directory (cd, cd Desktop, cd ~)

mkdir --- Create directory (mkdir new_folder, mkdir -p non_existant_folder/new_folder) Use mkdir -p if you're going to create a directory in a script. There are better ways but simple is best at first.

rmdir --- Remove directory (rmdir existing_folder)

cp --- Copy files (cp source destination)

mv --- Move and rename files(mv source destination)

rm --- Remove a file or folder(rm file, rm -r folder, !!!!!!rm -rf folder/with/contents!!!!!!)

man --- Read the docs(man ls)

chmod --- Change permissions (chmod +x some_file)

Written with StackEdit.