Skip to content

Instantly share code, notes, and snippets.

@winnab
Created January 24, 2017 20:24
Show Gist options
  • Save winnab/f42b1bda2f85341185ce02080389a047 to your computer and use it in GitHub Desktop.
Save winnab/f42b1bda2f85341185ce02080389a047 to your computer and use it in GitHub Desktop.

Console

  • Background: Shell
  • Varieties: C-shell, K-shell, Bash-shell (Bourne-again shell)

Bash shell

  • Uses bash scripting language, which was added to make using Bash easier
  • Allows you to add if statements, etc

Bash was a very early scripting language. Better to learn Perl or Python, which are easier to use.

  • Can't log in as root. Ubuntu makes life hard. Run sudo su root.
  • fdisk -l lists the contents of your drives
  • top let's you see stuff but it's blocking. instead, use ps aux.
  • | is a way in CS to connect two processes in memory. changed way developers process completely
  • stdin is always keyboard, stdout and sterr are screen. The | takes stdout and connects to next stdin
  • > redirects stdout redirects to a file instead of screen. > always overwrites and >> appends.
  • * is a wildcard. rm test* will remove any file that matches the wildcard pattern. ? stands for one character.

Everything in Unix is a file

Directories

  • /bin: contains binary files (executables)
  • /boot: contains kernel. contains file with how the kernel was configured. you don't do much here.
  • /dev: nothing to do here as administrator. stands for device. contains device files for all devices, including partitions (like sda1). all devices are represented here. who creates files? old times, admins had to play with them. now, the kernel does this automatically by scanning harddrive and creating device file (when you plug in a USB it creates device file then removes it when you eject)
  • /etc: as administrator, most important directory. this directory contains configuration files. everything. this is where you do configuration.
  • /home: place where normal users keep their home directories.
  • /initrd.img -> /boot/initrd.img-3.16.0-4.dmg:
  • lib: this is where the computer stores library files. as administrator, nothing to do here.
  • lib64: 64-bit version of libraries. as administrator, nothing to do here.
  • lost+found: forget the existence of this. it's a fake directory.
  • media: newer than mnt (in 2000s). this is an alternative mount point for drivers just to make it more user-friendly. when Ubuntu automatically mounts (and opens window) when you plug something in, this is the mount point.
  • mnt: mount. the mount point for all drivers. you cd here to mount into drivers.
  • opt: optional. hand-in-hand with usr. program files. if you install Apache, the main program files will be in usr. some applications traditionally go to opt and some go to usr.
  • proc: if the kernel has a process running behind the scenes which controls things (info flow etc), it'll be in proc. files are generated by the kernel. it's a virtual directory. when you open machine, it's created, and when you shut down, it disappears. full of technical info about memory/cpu/processes. the command ps aux goes to proc and displays info from there. for security, you can see when a process is trying to change name (virus). also more interesting is networking. you can see all the networking stuff there. directory is only there for information.
  • root: nothing more than the home directory of the root user. generally this should not be trashed with random files like docs or spreadsheets.
  • run: run is not a traditional Unix directory
  • srv: newer var directory where some files are stored. never seen any distro make actual use of this directory. always put it in var. may see it in the future.
  • sys: fake. doesn't exist.
  • tmp: two users. one wants to share with other. need a place where everyone has write access. tmp is the only directory in the Unix system where everyone has write access
  • usr: user. see opt
  • var: very useful. second most important directory. stands for various. here you find workings of servers. for example, var/log is where logs live (var/logs/apache, etc). it is traditional Unix.
  • vmlinux -> boot/vmlinux-3.16.0-4-amd64:
  • sbin: contains binary that only root can execute

Differences

  • Different distros sometimes store certain files in different places, but if you know what you're looking for, you should be able to find it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment