Linux Commands
Linux commands that I use frequently, yet seem to always forget:
- Finding files:
- find -name ‘mypage.htm’
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory. - find / -name ‘mypage.htm’
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root. - find -name ‘file*’
In the above example the system would search for any file beginning with file in the current directory and any subdirectory. - find -name ‘*’ -size +1000k
In the above example the system would search for any file that is larger then 1000k.
- find -name ‘mypage.htm’
- TAR
Note: .tgz and .tar.gz are the same thing, with respect to file names.- Creating
- tar -cvf filename.tar directory/
- tar -cvfz filename.tgz directory/
- Extracting
- tar -xvf filename.tar
- tar -xzvf filename.tgz
- Testing or Viewing
- tar -tvf filename.tar
- tar -tzvf filename.tgz
- If the file extension is in *.bz2, most linux OS’ come with “bunzip2″. Just type “bunzip2 <filename.bz2>”…and you should get a .tar file.
- Creating
- Environment (.bashrc, .profile) Refresh
- After making edits to your .bashrc or .profile (or whatever), type: source /directory/.profilename
- VI Stuff
- <insert>: Allows you to begin making changes to the file your working on.
- <ESC>: Takes you out of edit mode (insert mode).
- dd: Deletes an empty line.
- <:>: The colon key brings you to your command entry mode. From here, enter “wq” to write the changes to the file and quit out. Enter “q!” to quit out, and abandon all changes to the file you’ve made.
- General Crap
- df -h
This displays a simple readout of your disks, space utilized, free space, etc. - rm -rf directory/
This command deletes a non-empty directory tree. - mii-tool -v
Shows general stats on your ethernet cards. I’m not sure how common this feature is, as my Solaris box doesn’t have this feature. - uname -a
Shows all information about your linux kernel.
- df -h
