This course aims to teach students how to use the tools usually employed in daliy life.
Topic 1: The shell
We have to go old-school and drop down to a textual interface to make full use of the functions of a PC.What we need is shell.
Using the shell
My shell is like:
(base) myfile@192 ~ %
You can enter “data” to check the date.
(base) myfile@192 ~ % date
Wed Jun 22 21:39:05 CST 2022
Also we need to use echo to repeat the sentence:
(base) myfile@192 ~ % echo hello
hello
(base) myfile@192 ~ % which echo
echo: shell built-in command
(base) myfile@192 ~ % /bin/echo $PATH
/Users/myfile/opt/anaconda3/bin:/Users/myfile/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/Users/myfile/Desktop/nand2tetris/tools
We can find out which file is excuted for a given program name using the w h i c h which which program. We can also bypass $PATH enitirely by giving the path to the file we want to execute.
Navigation in the shell
we can see the pwd command and change with the cd command. In a path, . refers to the current directory, and … to its parent directory.
(base) myfile@192 ~ % pwd
/Users/myfile
(base) myfile@192 ~ % cd /home
(base) myfile@192 /home % cd ..
(base) myfile@192 / % pwd
/
(base) myfile@192 / % cd ./home
(base) myfile@192 /home % pwd
/home
pwd shows the current path and cd means enter the new path.
(base) myfile@192 / % ls
Applications Volumes etc sbin
Library bin home tmp
System cores opt usr
Users dev private var
(base) myfile@192 / % cd
(base) myfile@192 ~ % cd ./Desktop
(base) myfile@192 Desktop % ls
MIT6.828
Old_Homebrew
PAT甲级刷题
Screen Shot 2022-06-02 at 10.35.44.png
XuanhaoZhao.github.io-main
d2l-zh-pytorch.pdf
github项目
hw3
nand2tetris
~$st a test.docx
~$词话-王国维.pdf.baiduyun.p.downloading
博客行
大学物理问题汇总
本科阶段文件
课外书
(base) myfile@192 Desktop % ls
MIT6.828 hw3
Old_Homebrew nand2tetris
PAT甲级刷题 ~$st a test.docx
Screen Shot 2022-06-02 at 10.35.44.png 博客行
XuanhaoZhao.github.io-main 大学物理问题汇总
d2l-zh-pytorch.pdf 本科阶段文件
github项目 课外书
(base) myfile@192 Desktop %
ls will print the contents of the current directory.
mv(to rename / move a file)
cp(to copy a file)
mkdir(to make a new directory)
(base) myfile@192 ~ % man ls
Give the man program a try. It takes as an argument the name of a program, and shows you its manual page.Press q to quit.
Connecting programs
< file and > file let you rewire the input and output streams of a program to a file respectively.
(base) myfile@192 ~ % echo hello > hello.txt
(base) myfile@192 ~ % cat hello.txt
hello
(base) myfile@192 ~ % cat < hello.txt
hello
(base) myfile@192 ~ % cat hello.txt > hello2.txt
(base) myfile@192 ~ % cat hello2.txt
hello
(base) myfile@192 ~ %
cat is a program that concatenates files.