Some Unix bash beginners tips and handy tricks
02 Aug 2005 20:35 - (0) comments
Recently I have been doing a lot of *nix stuff. Here are some beginner tips and handy tricks I learned.
Getting started
The first thing most console users learn is that up and down browses through all previous commands. These previously used commands are saved and can be retrieved and edited in other sessions. A more advanced method to search in the history of previous commands is pressing ctrl+r.
Navigating through the file system
After getting started the first thing you'll want to do is move around in the file system. Use cd / and cd ~ to go to your root and home directory.
*nix has build in auto-completion for the file system. When typing the path to a file or directory press tab for auto-completion. If there are multiple possibilities this doesn't work. You can however press double tab to show the possible files or directories. After getting used to tab for auto-completion you'll be accidently using tab to auto-complete URL's in your browser in no time.
To view the contents of a directory use ls. If you want to see more information you can add the -l option. Because typing ll enter is a lot faster than typing ls enter or ls -l enter, you should add alias ll="ls -l" to your ~/.profile or ~/.bashrc file for listing directories at high speed.
Another common task is changing file permissions.
Use chmod 777 -R DIRNAME to set all files in the directory recursively to read/write/execute. If you don't own the file you can use sudo (SuperUserDO). But only use it when needed otherwise you may unwillingly change the owner to root.
Editing files
The standard editor for bash is vi and can be started with vi FILE_NAME. You can also use pico/nano or gedit. When using vi to edit files press i to start editing. When you are finished editing press esc and :wq to write the file and quit. To search forward in vi use /. To search backward use ?.
RTFM
And if you're not sure about a command you can always use man COMMAND_NAME to view the manual entry for a command.
Comments
No comments allowed.