New to Linux?¶
For those of you who are new to Linux, this page should provide a gentle introduction to the use of the terminal (command line), essentially the Bash shell.
No one should be asking for help if they have not tried searching for the answer themselves first. Google it!
It takes a pragmatic approach to leverage the most out of Google. You have to provide it with only the relevant information in order of significance and the better you get at doing this the better the results you will get.
|See:||How to search on Google|
What is a shell?¶
Let’s go back a bit:
|Q:||What is Linux?|
|A:||Linux is an operating system (OS).|
|Q:||What is an OS?|
|A:||An OS is the software component of a computer which operates the hardware component.|
Linux is a variant of UNIX, which was invented by Ken Thompson and Dennis Ritchie at Bell Labs in the 70’s. UNIX is based on a 3 layer model, meaning the OS is built in 3 layers:
OS (3 LAYER MODEL) ._________________. ________________________ | _______________ | \ / /\ ALIENS | I I | \ APPLICATIONS / / \ \__/ \__/ | I I | \ / / \ (oo) (oo) | I HARDWARE I | \________________/ / \ /~~\_/~~\_ | I I | \ / \ / _.-~===========~-._ | I_____________I | \ SHELL / \ / (___________________) !_________________! \ / \ / \_______/ ._[_______]_. \________/ \/ .___|___________|___. /\ \ / | | / \ KERNEL___\ / | | \ / \ / !___________________! \/ \/
As you can see in this canny illustration, the kernel component of the OS interacts directly with the hardware, while the shell is the first level of human (in this case, alien) interface.
How to access a shell¶
Windows does not have a Bash shell, it has a DOS shell which has very cut down features in comparrison to a shell on Linux. You can install an SSH client on Windows which you can use to login to a shell on a remote Linux server.
You can also login remotely using SSH, indeed this will be a regular task for you in research computing as you will need to access HPC clusters which you won’t find sitting on your desk! See How do I login to a remote server via SSH?
Once you are logged in, you will be presented with a cursor, waiting for your input, this is the command interpreter or shell.
How to use the Bash shell¶
You can send commands to Bash.
Everything in UNIX, and therefore Linux, is represented in the filesystem. This includes regular files and directories and even devices, i.e. terminals, mice, hard disks, USB, etc.
The filesystem starts with root, represented by a single forward slash (/) and everything is built on that in a system of directories and subdirectories that contain files, like trunks, branches and leaves of a tree. Knowing how to move around the filesystem and how to manage the files and directories in the command line is therefore absolutely crucial.
It probably isn’t practical to list all the commands available in Bash, especially when there is so much good information availbale, ready for you to search for, on the internet.
But to get you started and to give you an idea, here are some commands you might find immediately useful:
|ls||List a directory||ls -al ..|
|pwd||Print working directory||pwd|
|cd||Change directory||cd -|
|cp||Copy||cp -p <file1> <file2>|
|mv||Move||mv -f <directory1> <directory2>|
|rm||Remove||rm -fr <directory>|
|rmdir||Remove an empty directory||rmdir <directory>|
|cat||Concatenate a file||cat <file>|
|less||Similar to more!||less <file>|
The commnads and examples shown here are only very crude demonstrations of what possibilities are available. Significantly, some examples show the use of cammand options and you can find what these mean in the man pages by entering man <command>.
Naturally there are a multitude of commands available on a typical Linux system. To help you get started, you might find this useful:
The man pages are the most definitive source of information for all the commands available on Linux. All the options for a command and the format of how to apply them, and even examples, can be found in the man pages. So always use it for checking up on any command.
Along with Google and a bit of your intuition you will be able to find everything you need to know about Linux commands. Have fun on your journey!
Use TAB for autocomplete (hit TAB twice). Strongly encouraged to use autocomplete to avoid typos. Can be used for commands as well as files/directories.