Linux Basics

OUTLINE

  • What is Linux?
  • Basic Concept
  • Basic Command
  • Permissions
  • Text Editor "vi"

What is Linux?

Linux

1. free and open-source software operating system kernel

 

2. the one of Unix-like operating systems with GNU

 

3. developed by  Linus Torvalds at first

Basic Concept

shell

A program that takes keyboard commands and passes them to the operating system to carry out.

"bash"(Bourne Again SHell)

File System

File System

  • a tree begins from the root "/"
  • "." means the current directory; ".." means the former directory 
  • route:
    • absolute => from "/"
    • relative => from "."

/home/<user_name>

=> home directory, "~"

/bin

=> important system execution file

/var

=> data and log

/tmp

=> temporary file

/dev

=> "dev" means "device", mount devices' directory

/etc

=> setting files

User

  • normal user => "$"
    • multi-user and multi-operation system
  • root => default superuser, "#"

Basic Command

who

     => find the user which is online.

 

whoami

     => find the current user

sudo

     => execute the command as root

     => need the "user" password

 

su

     => change the user to root

     => need the "root" password

ls

(ls [parameter] [route])

     => means list, to list the directory and file

     >> parameter:

          > -a => show all the file and directory

          > -l  => show by list

      >> parameter can be juxtaposed.

          > e.g.  ls -al

pwd

     => means print working directory

 

clear

     => clean the scene

mkdir

(mkdir [directory_name])

     => means make directory

     >> parameter:

          > -p => make multi-layer directory

                  => e.g. mkdir -p [dir1]/[dir2]

 

rmdir

(rmdir [directory_name])

     => means remove directory

     => only can remove EMPTY directory

cd

(cd [route])

     => means change directory

     => e.g. cd .. (change to the former layer)

     => e.g. cd - (change to the previous layer)

touch

(touch [file_name])

     => create an empty file

     => without any type

mv

(mv [parameter] [source] [target])

     => move single file or directory

     >> parameter:

          > -i => ask

          > -f => force

cp

(cp [file1] [file2])

     => copy file or directory

rm

(rm [parameter] [file_name/directory_name])

     => remove file or directory

     >> parameter:

          > -f => force

          > -i => ask

          > -r => recursive

cat

(cat [file_name])

     => print file content

 

echo

(echo [string])

     => print string on the scene

less

(less [file_name])

     => browse file content

     >> operate:

          > j => up

          > k => down

          > q => quit

man

(man [command])

     => means manual to find the explain of command

     >> operate:

          > q => quit

LAB

1. Create a file called “myFirstTouch”

2. Create a directory called “myDir”

3. Move the file to the directory

4. Create another directory called “newDir” and move “myDir” in it.

5. Remove the directory “myDir”

6. Remove the directory "newDir"

Permissions

while we use command "ls -al":

 drwxrwxrwx  sirla   sirla  8288 Aug 26 07:32  helloworld

[permission] [owner] [group] [size] [last edit time] [name]

drwxrwxrwx

[type][owner][group][world]

[type]

> d => directory

> - => file

 

permission:

> r => read

> w => write

> x => execute

> - => no permission

chmod

(chmod [parameter] [file_name])

      => modify the permission

      >> parameter:

          > u => user

          > g => group

          > o => others

          > a => all

          > + => add

          > - => remove

          > = => assign

Use octal to present the permission:

(no permission => 0; have permission => 1)

      0 - 000    => ---

      1 - 001    => --x

      2 - 010    => -w-

      3 - 011    => -wx

      4 - 100    => r--

      5 - 101    => r-x

      6 - 110    => rw-

      7 - 111    => rwx

LAB

1. Create a file called “forOwner”

2. Modify the permission that only the owner can write the file and execute it.

3. The group can read but can't execute it

4. The world can't even read it

Text Editor "vi"

"vi" mode

  • Command mode
  • Insert mode
  • Last line mode

Basic Operation:

> j => up

> k => down

> h => left

> l => right

> i => Insert mode

> Esc / Ctrl + [ => Command mode

> : => Last line mode

Last line mode command:

> :q => exit without save

> :q! => (forced) exit without save

> :w => save

Advanced Operation

LAB

1. Download the file with
        `curl -L https://goo.gl/afA3PX -o lab03.txt`

2. Open and practice the file

Linux Basics

By Иo1lz

Linux Basics

  • 107