Home of Rob
Menu
Linux Shell Prompt - Beginners Guide
I've got a page on this website that covers some basic commands for the Linux shell, but I don't think it'll hurt to have another introduction to what can be a fairly intimidating and opaque area for the beginner (or someone used to using windows). So here are some useful commands if you're new to the Linux shell and want to just do the basic stuff (move round the directory tree, copy files, view file content).
Navigating the Directories
ls
- List the content of the current directory.
ls *.log
- List only files ending in .log
ls -lh
- List with more details (time stamps, sizes etc.)
cd
- Change directory (e.g. 'cd logs')
cd ..
- Move to directory above this one
cd -
- Move to the previous directory you were in.
pwd
- Print the current directory (if you aren't sure where you are)
Note:
When you first start up the command shell you'll be in your home directory. This is specified as '~', and explicitly is '/home/
Viewing File Content
more
- You can use this to view the contents of a log file (e.g. 'more DebugLog.log'). Press space to view the next page, b to move back and q to quit.
tail
- This prints the end of a file (e.g. 'tail DebugLog.log'). Use the -n option to display more lines (e.g. 'tail -n 100 DebugLog.log' to display 100 lines)
Moving and Removing
rm
- Delete a file (e.g. 'rm DebugLog.log') - note that there's no confirmation. Once it's been removed, it's gone forever! System important files are protected so you won't be able to accidentally bring linux down (unless you start using 'sudo rm', which isn't recommended, unless you know what you're doing.)
cp
- Copy a file (e.g. 'cp DebugLog.log logs/')
mv
- move a file (e.g. 'mv DebugLog.log logs/')