CS代写 – you should know the following shell concepts

– you should know the following shell concepts
– hierarchical file system
– directory tree
– root directory

Copyright By PowCoder代写 加微信 powcoder

– home directory
– standard directory contents
– /etc: configuration files
– /dev: device files
– /home: user home directories
– /lib: shared library files used by core systems programs
– /sbin: system binaries for vital system tasks
– /usr: programs and support files for users
– /var: system log files
– absolute path: starts with root directory, that is “/”, and specifies a
complete path for a file or a directory, e.g. /usr/bin/firefox
– relative path: specifies the path for a file relative to the current
directory; e.g. if the current directory is /usr, then ./bin/firefox is a
relative path for the firefox binary
– types of shell commands
– binary files: separate programs executed by shell
– shell builtins: commands interpreted by shell, the functionality for these
commands are implemented in the shell program itself
– aliases: shortcuts defined by users to avoid typing of long commands or
command sequences
– shell variables: variables that a user can set to control shell’s behavior
– PATH: when a user types a command, shell looks for the binary in the list
of directories present in the PATH variable.
– input/output redirection
– every program executed in shell has three streams associated with it
– standard input: where the program reads the input from; attached to
keyboard by default
– standard output: where the program writes its output; attached to screen
by default
– standard error: where the program writes its errors; attached to screen
by default
– shell allows us to redirect these streams from their defaults
– use > to redirect standard output to a file:
– ls -l /usr/bin >ls-output.txt
– use >> to append standard output to a file; using >> will append to a
file whereas using > will wipe the output of the file first before
writing to it; thus, after the following commands, the file ls-output.txt
will have twice the contents of the /usr/bin directory:
– ls -l /usr/bin >ls-output.txt
– ls -l /usr/bin >>ls-output.txt
– use 2> to redirect standard error to a file:
– ls -l /nonexistentfile 2>ls-error.txt
– use < to read input from a file instead of keyboard: - cat < /etc/passwd - shell allows us to send the output of one program to the input of another program using pipe (|). the following command sequence sends the output of "ls -l /usr/bin" command to the input of "less" command for easier - ls -l /usr/bin | less - shell allows us to form powerful pipelines to perform arbitrarily complex tasks. see the lecture for an example. - you should know the following shell commands; use tldr command to find out the most frequently used forms of these commands: - the following is an example shell session. you should be able to understand and explain what is going on: demo Documents Music Templates Videos Desktop Downloads Public typescript bin dev lib libx32 mnt root snap sys var boot etc lib32 lost+found opt run srv tmp cdrom home lib64 media proc sbin swapfile usr . .config .gitconfig Public typescript .. demo .gnupg .ssh Videos .bash_history Desktop .local .sudo_as_admin_successful .bash_logout Documents .mozilla Templates .bashrc Downloads Music .thunderbird .cache .emacs.d .profile .tldr demo Documents Music Templates Videos Desktop Downloads Public typescript demo: directory file demo.c demo.c: C source, ASCII text cat demo.c #include

int main() {
printf(“welcome to git demo!\n”);
printf(“Nice to meet you!”);
alias alert=’notify-send –urgency=low -i “$([ $? = 0 ] && echo terminal || echo error)” “$(history|tail -n1|sed -e ‘\”s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//’\”)”‘
alias egrep=’egrep –color=auto’
alias fgrep=’fgrep –color=auto’
alias grep=’grep –color=auto’
alias l=’ls -CF’
alias la=’ls -A’
alias ll=’ls -alF’
alias ls=’ls –color=auto’
alias deepdir=’mkdir a; cd a; mkdir b; cd b; mkdir c; cd c’
alias alert=’notify-send –urgency=low -i “$([ $? = 0 ] && echo terminal || echo error)” “$(history|tail -n1|sed -e ‘\”s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//’\”)”‘
alias deepdir=’mkdir a; cd a; mkdir b; cd b; mkdir c; cd c’
alias egrep=’egrep –color=auto’
alias fgrep=’fgrep –color=auto’
alias grep=’grep –color=auto’
alias l=’ls -CF’
alias la=’ls -A’
alias ll=’ls -alF’
alias ls=’ls –color=auto’
mkdir: cannot create directory ‘a’: File exists
mkdir: cannot create directory ‘b’: File exists
mkdir: cannot create directory ‘c’: File exists
rmdir: failed to remove ‘a’: Directory not empty
type deepdir
deepdir is aliased to `mkdir a; cd a; mkdir b; cd b; mkdir c; cd c’
unalias deepdir
type deepdir
bash: type: deepdir: not found
demo Documents Music Templates Videos
Desktop Downloads Public typescript
rmdir Videos
mkdir Videos
demo Documents Music Templates Videos
Desktop Downloads Public typescript
cp /etc/passwd x
x: ASCII text
cp /etc/passwd Documents/
ls Documents/
cp /etc/passwd Documents/mypasswd
ls -l Documents/
-rw-r–r– 1 neo neo 2744 Feb 2 07:50 mypasswd
-rw-r–r– 1 neo neo 2744 Feb 2 07:49 passwd
mv Documents Templates/
demo Desktop Downloads Music Public Templates typescript Videos x
ls Templates/
ls Templates/Documents/
mypasswd passwd

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com