Basic Linux

From DeepSense Docs
Revision as of 17:41, 6 March 2019 by Lyang (talk | contribs) (Created page with "Introduction to Linux <div class="noautonum"> This introduction is aimed at users that do not have much Linux background. This is a brief introduction, but not a Linux less...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction to Linux

This introduction is aimed at users that do not have much Linux background. This is a brief introduction, but not a Linux lesson. To learn more basics of Linux, users can find a lot of tutorials searching by keywords like "Linux Command Basics", "Linux Tutorial for Beginners", etc.

1. Linux shell

A Linux shell is a program that the operating system interacts with you directly. It receives user commands, executes them, and may output the results to users. Then the shell prompts you for another command. To learn more about Linux shell, you can go the the following webpage: http://linuxcommand.org/lc3_lts0010.php.

2. Linux on DeepSense

DeepSense uses Redhat Enterprise Linux as its OS on all machines. To interact with DeepSense platform, users would need to learn some basics of Linux. Your first Linux command to interact with DeepSense platform would be "ssh username@login1.deepsense.ca" or "ssh username@login2.deepsense.ca". After you log in DeepSense, you will see your username and the server name in a prompt where you can issue commands:

[username@ds-lg-01 ~]$

Users can always obtain help of Linux commands by entering:

[username@ds-lg-01 ~]$ man command

For example, command:

[username@ds-lg-01 ~]$ man ls

shows you the help information of "ls" command which lists your files and directories in the current or specified directory.

3. Some basic and important commands

After you log in, you are in the shell and able to type commands. Some basic and important commands are:

ls: list your files and directories
cd: enter a different directory
mkdir: create a directory
rm: remove file(s) 
rmdir: remove directories
cat filename: view the contents of a file
cp: copy file(s) from one location to another (or the same) location
scp: remotely copy file(s) from machine to machine 
pwd: list the name of current/work directory
mv: rename a file or a directory

Each command above can have multiple parameters to show more specific and detailed information. Users can always use "man command" to see detailed explanations of parameters.

4. Editting a file

There are editors from different providers for users to create, edit, and save their files on Linux. One we often use is Vim or Vi IMproved. To see details how to use VIM to edit files, please refer to https://www.linux.com/learn/vim-101-beginners-guide-vim.

5. File permissions

Using command "ls -l", users can see the details of file(s) in the current directory. The first column in the output is the file/directory permissions. Basically, this column is broken into 4 sections with 10 characters: type of the file/directory, read, write, and execute permissions for the owner of the file/directory, read, write, and execute permissions for the group members of the group owning the file/directory, and read, write, and execute permissions for other users.

The first character indicates the file type :

-: a file
d: a directory
l: a symbolic link

Then, from left to right, this command shows read, write and execute permissions of the owner, the group and other users. Here are some examples :

drwxrwxrwx: a world-readable and world-writable directory
drwxr-xr-x: a directory that can be listed by everybody, but only the owner can add or remove files
-rwxr-xr-x: a world-readable and world-executable file that can only be changed by its owner
-rw-r--r--: a world-readable file that can only be changed by its owner.
-rw-rw----: a file that can be read and changed by its owner and by its group
-rw-------: a file that can only be read and changed by its owner
drwx--x--x: a directory that can only be listed or modified by its owner, but all others can still pass it on their way to a deeper subdirectory
drwx-wx-wx: a directory that everybody can enter and modify but where only the owner can list its contents