[EE485] March 15th Class - Linux & Shell

Jin woo Kim·2024년 3월 15일

what is a shell?
Gets command from the user and runs the command on OS.

  1. sudo, su, and man
    $sudo [command]: Superuser-do: runs a command as root
    ex) $sudo shutdown -h now
    : Runs 'shutdown -h now' as root, asks for the root password before running the commnand.

$su [user-to-be-switched-to]

$man [command]: shows the manual of command
ex) $man sudo

  1. Directory Layout, and commands related to directories/files

In the highest, root directory. (This is not the same with root access.)

$ls: list directory contents

$cd [dir]: switches the current directory to [dir]
If [dir] is missing, it goes to your home directory.

ex) $cd ./temp

$pwd: Displays the present working directory name (present working directory)

$cat [files]: concatenates and displays files

mkdir[dir]mkdir [dir] rmdir [dir] :create/remove [dir]

$rm [files]: remove files

$rm -r

$mv [A][B]: Move file A to file B (rename and/or relocate A)
ex) $mv a.txt ~/tmp/ //relocate a.txt to b.txt
$mv a.txt b.txt //rename a.txt to b.txt
$mv a.txt ~/tmp/b.txt //rename and relocate a.txt
$mv ./tmp tmp2 //rename a directoty,

cf) ~/ : home directory
./ : current directory

  1. Miscellaneous & Environment Variables

echo[argument]:displaysarguementstothescreenecho [argument]: displays arguements to the screenexit/logout/ctrl-d: exits the shell or your current session
$clear: clears the screen

What is Environment Variables?
PATH???PATH ???HOME ???

  1. which and -h option
    which [command]: displays the location of command
    whichls//output:/bin/lswhich ls //output: /bin/lswhich which //output: /usr/bin/which

Hints: -h option
[command] -h

  1. Working with Directories
    Special Directory
    . : this directory
    ..: Parent directory
  • : previous directory
  1. How to Execute a Program in Current Directory?
    You should specify the directory
    program//doesntworkprogram //doesn't work./program //GOOD!

  2. Creating/Removing Directories
    $mkdir/rmdir -p dir: creates/removes all intermediate directories in dir

ex) $mkdir newdir //works
$mkdir newdir/product/reviews //mkdir: cannot create directory
$mkdir -p newdir/product/reviews //works
$rmdir newdir //rmdir: failed to remove 'newdir': Directory not empty
$rm -rf newdir //works, -f means 'force'

  1. Listing Files with ls
    ls:justlistingls : just listingls -l: Gives whole bunch of things together.

other options
-a: all files including hidden files
-t: sort by modified time
-d: displays only directory names not their contents
-R: list files recursively

  1. File permission
    10 characters.

first character: file type
'-' regular type
'd' directory
'l' symbolic link (pointer file)
Permissions:
r: readable
w: writable
x: executable
Groups:
u: user텍스트
g: group
o: other

profile
Data Science / Economics / Study 요약

0개의 댓글