1 of 24

Advanced Linux

Sign in at: tinyurl.com/ufosc17

2 of 24

Announcements

  • Project Status
    • Club Website is looking for design ideas
    • Marston vs West has video of progress on slack
  • Casual Coding Sessions
    • Wednesday 4PM - 6PM in Marston, Room Darwin
    • Thursday 5PM - 7PM in Marston, Room Nye
  • Club Survey
    • Help us out and you may win a shirt or sticker!
    • On our Facebook page
  • Mozilla Collab
    • Next Wednesday
    • Working on Open Source Projects

3 of 24

Last time on...

  • Previous presentation
    • Information about installing Ubuntu
    • Basic navigation
    • How to install/update programs

4 of 24

What is a .. ?

  • Shell
    • Actual program that runs commands
    • Bash, Zsh, Fish, etc
  • Terminal
    • GUI into the shell
    • Open up on a desktop
    • Usually open up at home directory
  • Console
    • No GUI, just the shell
    • TTY (TeleTYpewriter)
    • Ctrl + Alt + F1-6
      • Ctrl + Alt + F7 goes back to GUI

5 of 24

Terminal Shortcuts

  • Kill current process
    • Ctrl + C
    • Sends a SIGSTOP to process
  • Stop current process
    • Ctrl + Z
    • Sends a SIGINT to the process
  • Copy
    • Ctrl + Shift + C
  • Paste
    • Ctrl + Shift + V

  • Look at previous command
    • Up arrow
  • Autocomplete
    • Tab
    • Finish spelling
    • Files and folders
  • See history
    • history
    • Run command with !<Line Number>
    • !! is the last command

6 of 24

Basic Commands

  • List files and folders
    • ls
    • Long format and all files
      • ls -la
  • See current directory
    • pwd
  • Change Directory
    • cd <directory name>
    • Go up a directory
      • cd ..

7 of 24

Basic Commands (cont.)

  • Make a file
    • touch <Filename>
    • Doesn't modify existing file
  • Make a directory
    • mkdir <Folder name>
  • Remove file
    • rm <Filename>
  • Remove folder
    • rm -r <Foldername>

8 of 24

Starting a Program

  • Execute a file
    • ./<Executable file>
    • Shell script or C out file
  • Run program as a child
    • <Program>
    • Command line or GUI
  • Run command as a new process
    • <Program> &
    • Closing the terminal dosen’t kill the program
  • Leave a session
    • exit
    • For things like ssh

9 of 24

Basic Commands Practice

  • Check current folder
    • pwd
  • Make a file
    • touch temp.txt
  • See file
    • ls
  • Remove file
    • rm temp.txt
  • Look at root directory
    • ls /

10 of 24

File System

  • Can vary based off distro
    • Mostly the same
  • /
    • Called root
    • Uppermost directory
  • /bin
    • Common system programs
  • /boot
    • Boot files
    • Boot loaders (Grub) are located here
  • /dev
    • References to CPU peripheral hardware
  • /etc
    • Program config files
  • /home
    • Contains all home directories
  • /lib
    • Libraries
  • /lost+found
    • Files saved during failures

11 of 24

File System (cont.)

  • /mnt
    • Mount point for external media
  • /opt
    • Third party software
  • /proc
    • Virtual file systems for system resources
  • /root
    • Root user's home directory
  • /sbin
    • Common system programs which require root permissions
  • /tmp
    • Temporary space
    • Cleaned on reboot
  • /usr
    • User related programs and libraries
  • /var
    • Storage for variable files like logs

12 of 24

Users and Groups

  • Each login is a user
    • Can use either Command Line or GUI
  • Home directory
    • Where the user saves all their data
    • Found at /home/<user name> or ~/
  • Root user
    • Has full control of OS
      • Create and remove users
      • Install and remove software
    • Can grant other users superuser privileges
  • Groups give access rights
    • To files and folders
    • Certain programs
    • Access to things like printers
  • A user may be in many groups
  • Wheel group
    • Access to superuser privileges

13 of 24

Sudo and Su

  • Allow a user to act like root
  • Must be very careful
    • There is a reason it’s a privilege
  • Run a single command as root
    • sudo
  • Run every command as root
    • su
  • Must enter in password

14 of 24

Permissions

  • See file permissions
    • ls -l
    • -rw-r--r-- 1 matthew matthew 0 Nov 5 18:24 temp.txt
  • Mode
  • Number of hard links
  • User and Group
    • If no group then the user
  • File size in blocks
  • Date and time
    • Last modified
  • File name

15 of 24

Permissions (cont.)

  • drwxrwxr--
  • Letters
    • Read = 4
    • Write = 2
    • Execute = 1
    • Directory/Link
  • Meanings
    • User
    • Group
    • Everyone else

16 of 24

Change Permissions

  • Change owner and group
    • chown <User>:<Group> <File>
      • chown matthew the.txt
      • chown :humans doctor.txt
  • Change permissions
    • chmod <Group>+<Permissions> <File>
      • chmod o+wr star.txt
      • chmod ug-x wars.txt
    • chmod ### <File>
      • chmod 421 star.txt
      • chmod 777 trek.txt

17 of 24

Permissions Practice

  • Make a directory
    • mkdir temp
  • See permissions
    • ls -l
  • Remove all permissions
    • chmod 000 temp
  • Try accessing
    • cd temp
  • Change back
    • chmod 300 temp
  • Try again
    • cd temp

18 of 24

Various Tools

  • See list of processes
    • top
  • End a process
    • kill <pid>
  • Find where a program is
    • whereis <Program>
  • See all the logged in users
    • who
  • Information about a program
    • man <Program>
  • Shutdown
    • shutdown
  • Reboot
    • reboot
  • Schedule programs to run
    • crontab <File>
    • Or edit cron file

19 of 24

Web Tools

  • Check internet connection
    • ping <Url>
  • Download a file from internet
    • wget <Url>
  • Log in to a remote PC
    • ssh <User>@<Hostname>
  • Share files between remote PCs
    • sftp <User>@<Hostname>
  • GUI log in to a remote PC
    • ssh -X <User>@<Hostname>
    • <GUI Program>&

20 of 24

Dev Tools

  • View text
    • less <File>
  • Edit text
    • vim <File>
    • emacs <File>
    • nano <File>
  • Have multiple terminals open
    • tmux
  • Compile programs
    • make
    • Needs makefile

  • Differences between a file
    • diff <File1> <File2>
    • Patchfiles
  • Find a file in a directory
    • find . -name "<File>" -print
  • Find a string in a file
    • grep <pattern> <file>
    • grep ”Star Wars” movies.txt

21 of 24

Other Command Line Tools

  • Tons of other commands
  • Search what you want + bash and you’ll find something
  • Look through man pages

22 of 24

Run Windows Programs

  • WINE
    • Windows Is Not Emulated
  • Install WINE
    • sudo add-apt-repository ppa:ubuntu-wine/ppa
    • sudo apt install wine
  • Install app
    • Check compatibility
    • https://appdb.winehq.org/
      • Note any issues/workarounds
    • Download executable
    • Install with WINE
    • Run

23 of 24

Resources

24 of 24

Other things?

  • Grub
  • Server
  • Docker intro
  • Snap/Flatpack
  • Screen share