180 likes | 374 Views
Unix Tutorial. Common Directory Commands. ls List directory contents cd {dir} Change working directory to {dir} pwd Print working directory mkdir Make a new directory rmdir {dir} Delete directory {dir}. Example. > cd lab1 > pwd /home/3/yourusername/lab1 > ls
E N D
Unix Tutorial The Ohio State University
Common Directory Commands • ls List directory contents • cd {dir} Change working directory to {dir} • pwd Print working directory • mkdir Make a new directory • rmdir {dir} Delete directory {dir} The Ohio State University
Example > cd lab1 > pwd /home/3/yourusername/lab1 > ls a.out first.cpp first.cpp~ > cd > pwd /home/3/yourusername The Ohio State University
Example > cd > pwd /home/3/yourusername > mkdir lab2 > cd lab2 > pwd /home/3/yourusername/lab2 > ls > The Ohio State University
Common File Commands • cp {f1} {f2} Copy file {f1} into {f2} • mv {f1} {f2} Move file {f1} to {f2} • rm {f1} Delete file {f1} • g++ {f1} Compile C++ file {f1} using g++ compiler. The Ohio State University
Example > cd > pwd /home/3/yourusername > mkdir lab2 > cp lab1/first.cpp lab2/second.cpp > cd lab2 > ls second.cpp > The Ohio State University
Example > cd lab2 > ls second.cpp > g++ second.cpp > ls a.out second.cpp > rm a.out > ls second.cpp > The Ohio State University
More File Commands • more {f1} View file {f1} • less {f1} View file {f1} • emacs {f1} Edit file {f1} using emacs • lp –d lj_cl_112_a {f1} Print file {f1} on printer lj_cl_112_a. The Ohio State University
More Unix Commands • control-C Interrupt a program or command • control-Z Suspend a program • bg Place suspended program in background. • fg Place suspended program in foreground. • jobs List background programs. The Ohio State University
Example of Background Jobs > emacs first.cpp & [1] 29943 > jobs [1] + Running emacs first.cpp > emacs second.cpp & [2] 29945 > jobs [1] + Running emacs first.cpp [2] – Running emacs second.cpp The Ohio State University
Example of Background Jobs > jobs [1] + Running emacs first.cpp [2] – Running emacs second.cpp > fg emacs first.cpp <control-Z> Suspended > bg [1] emacs first.cpp & The Ohio State University
emacs Example > emacs first.cpp g++ first.cpp The Ohio State University
emacs Example > emacs first.cpp g++ first.cpp ls The Ohio State University
emacs Example > emacs first.cpp g++ first.cpp ls Why won’t my computer respond? What’s wrong? The Ohio State University
emacs Example > emacs first.cpp g++ first.cpp ls Why won’t my computer respond? What’s wrong? Please help me Mr. Instructor. The Ohio State University
emacs Example Either: • Use the ‘&’ to place the emacs program in background, i.e.: > emacs first.cpp & [1] 29943 > Or: • Close the emacs window before issuing any other commands. > emacs first.cpp > The Ohio State University
List of Common Unix Commands • ls List directory contents • cd {dir} Change working directory to {dir} • pwd Print working directory • mkdir Make a new directory • rmdir {dir} Delete directory {dir} • cp {f1} {f2} Copy file {f1} into {f2} • mv {f1} {f2} Move file {f1} to {f2} • rm {f1} Delete file {f1} • g++ {f1} Compile C++ file {f1} using g++ compiler • more {f1} View file {f1} • less {f1} View file {f1} • emacs {f1} Edit file {f1} using emacs • lp –d lj_cl_112_a {f1} Print file {f1} on printer lj_cl_112_a • control-C Interrupt a program/command • control-Z Suspend a program • bg Place suspended program in background. • fg Place suspended program in foreground. • jobs List background programs. The Ohio State University