COSC102 Notes


Terminal VS. Shell

The terminal is an application/program that can be used to issue commands to the computer. Runs a shell.

The shell is the layer that transfers the command from the keyboard to the actual OS.


Linux and Unix

The kernel is the core part of a computer that manages hardware. An operating system is software that manages hardware and software and provides user services. Unix is a complete multiuser OS, and Linux is a Unix-like kernel that becomes a full OS when combined with tools and applications.


Terminal commands and uses:

Command Use Example Additional Notes
ls List files in the current directory. For more detailed listing of the directory contents, type " -l" after "ls." ls_example
  • -a -- see hidden files
  • -l -- more information
cd Moves to a different directory. Type "cd .." to go back one directory. cd_example.png
pwd Verifies your current directory. pwd_example
mkdir Makes a directory mkdir_example
rm Removes a file or directory. To remove a directory, add "-r" before the folder name. Does not give warnings. rm_example
rmdir Removes a directory only if it's empty. rmdir_example
mv Moves a file or a directory or renames them mv_example
ssh Connects to other machines ssh username@hydra0.eecs.utk.edu
nano Text Editor
vi/vim Another text editor. To exit, press esc then type ":q"(exits without saving). Press enter after.
  • vim is a terminal-based text editor
  • Three main modes: Normal (cannot type text/command mode), insert mode (where you actually type text), and command-line mode (save, quit, searching)
  • How to enter/exit insert mode: i -- insert at cursor; a -- insert after cursor; o -- open new line below; O -- open new line above
  • To exit insert mode press esc.
  • Command line mode: :w --> save; :q --> quit; :wq --> save and quit; :q! --> quit without saving
g++ C++ Compiler. Makes an executable from C++ course code files.
  • simple g++ source.cpp
  • g++ -o exec_name source(s)
  • g++ -std=c++11 -o exec source(s)
clear Clears the screen. clear
cp Copies a file. Input the name of file you want to copy after cp, if you want to specify the destination of the new file, input it after. cp_example
  • scp -- copy variant, for transfer from one machine to another -- scp ~ username@hydra12.eecs.utk.edu:path
man Short for "manual." Quick and easy way to access useful documentation on any command. Type it before any command. man_example
w Shows who is logged on and what they are doing. w
who Shows who is logged on and where they are who
chmod Changes file or directory permissions chmod 755 test.cpp
  • user, group, world
  • IMPORTANT(TEST): r=read=4, w=write=2, x=execute=1
  • Number beside chmod is sum.
  • (ex.) 7 -- can read, write, and execute; 5 -- can read and execute
  • Default = 700
  • (ex.)chmod 755 -- user:7; group:5; world:5
  • 0: nothing
lscpu Shows detailed information about your CPU in a clean, human-readable format
lshw Shows detailed information on system's hardware.
hostname -i Prints IP address(es) associated with your machine's hostname hostname -i