{"id":22289234,"url":"https://github.com/zvory/unix-101","last_synced_at":"2026-01-05T22:47:00.317Z","repository":{"id":85555327,"uuid":"153814898","full_name":"zvory/Unix-101","owner":"zvory","description":"Unix 101 for the Computer Science Club, University of Waterloo","archived":false,"fork":false,"pushed_at":"2018-10-19T20:04:32.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T18:42:19.135Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zvory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-19T16:55:25.000Z","updated_at":"2018-12-19T07:28:55.000Z","dependencies_parsed_at":"2023-07-20T11:30:45.449Z","dependency_job_id":null,"html_url":"https://github.com/zvory/Unix-101","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvory%2FUnix-101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvory%2FUnix-101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvory%2FUnix-101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvory%2FUnix-101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zvory","download_url":"https://codeload.github.com/zvory/Unix-101/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245543574,"owners_count":20632676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T17:08:37.395Z","updated_at":"2026-01-05T22:47:00.268Z","avatar_url":"https://github.com/zvory.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unix 101.\n\nTodo:\n - [x] rearrange emoji\n - [ ] finish first draft\n - [ ] proofread\n - [ ] get people to review\n \n\nWe'll be covering these topics:\n - Why people use the shell 🤔\n - Basics of shell interaction \n   - `echo`, `touch`, `ls`, `less`, `mkdir`, `mv`, `cp`, `cd`, `rmdir`, and `man`\n - Super basic `vim` intro\n - Some fun commands :slightly_smiling_face:\n - How to install new programs (Mac / Linux) :hammer_and_wrench:\n - Writing a simple script :writing_hand:\n - `history`\n - Further learning! `ssh`, `git`, `tmux`, `scp`, `vim`, `.bash_aliases`, hidden files.\n \n\n## Why people use the shell\nThe shell (also called terminal, or command line, I'll be using these interchangeably) is really powerful, a lot more powerful that programs with GUI's (Graphical User Interfaces).\nLots of programs only really work for the command line, and almost every software professional :woman_technologist: knows their way around it.\n\n## Basics of shell interaction\n\n\n### Opening the terminal\nLinux :penguin:: On Ubuntu, Ctrl+Alt+T will open a Terminal. Otherwise, this might depend on your Linux distribution.\n\nMacOS :apple:: Open up the application called Terminal. In the future, if you start to use the terminal more, you may want to install [iTerm2](https://www.iterm2.com/), as it's much more powerful and nicer.\n\n### The terminal prompt\nWhen you open the terminal, you will see something like this (The screenshot was taken on Ubuntu 17.04):\n\n![Terminal Screenshot](https://raw.githubusercontent.com/zvory/Unix-101/master/TerminalScreenshot.png)\n\nThis is the terminal prompt. This is where you enter commands. You can see there's some text there already, the terminal will print this out when it's ready to accept commands from you, the default text it prints out is:\n\n`username@machine-name:your-working-directory`\n\nYou might see that the `your-working-directory` part of the prompt is `~`. In the terminal, `~` is shorthand for your **home directory**.\n\n### Hello world (echo) :speaking_head:\n\nLet's try to print \"Hello world!\". The terminal command to display a line of text is `echo`. So lets put this command into the terminal:\n\n`echo \"Hello world!\"`\n\nAnd press enter. You should see the text \"Hello world!\" printed back at you.\n\nCongrats :party_popper:, you've made a Hello world! program in the terminal.\n\n### Creating a file (touch) :point_down:\nLet's make a file. In a GUI program with a nice user interface, we might right click in the program, and click 'New File', but we can't do that in the terminal.\n\nInstead we will use a command called `touch`. This will create an empty file for us. Let's type `touch myFile.txt` into the terminal.\n\nOnce you've done that, you might notice you don't get any feedback, there's nothing that says \"File created succesfully\" or anything, you just see a new prompt to enter a new command. This is normal, in Unix there is a convention that if a program doesn't output anything, it executed succesfuly.\n\n### Finding the file we just created (ls) :mag:\nRemember the `your-working-directory` part of the terminal prompt we talked about earlier? That is where your terminal is currently open to. When we used `touch`, the file we created was created in the `your-working-directory`.\n\nLets list the files in our current directory. To do this, we use the command called `ls` \n\n \u003e :thought_balloon: `ls` Sounds kinda like \"list\". Often times unix commands will be really short, like `rm` instead of \"remove\", this is so you have to type less).\n\nAt this point, our terminal might look something like this (The specific files and folders you see will probably be different from mine):\n\n![Terminal Screenshot](https://raw.githubusercontent.com/zvory/Unix-101/master/lsOutput.png)\n\nAfter we use the `ls` command, we will see a bunch of file and folder names in our terminal.\n\nMost importantly, we will see the name of the file we created earlier, `myFile.txt`.\n\n### Printing the file we created (less, cat) :page_facing_up:\nTo print a file, we can use either `cat` (which stands for concatenate) or `less` (the opposite of `more`, which is an old file viewer program).\n\nAs you might expect, to view the file we created type in `less myFile.txt` or `cat myFile.txt`. \n\n\u003e :thought_balloon: Note, you don't have to type in the entire filename, try typing in `less myF` and then pressing the Tab key. Your shell will try to autocomplete the filename, saving you time. Your shell will also try to do this with directories.\n\n### Editing the file (nano, vim, emacs) :writing_hand:\nTo edit the file, we'll use a simple editor called `nano`. Most people don't use `nano` for anything but quick editing jobs, but editors that run in the terminal are notoriously unintuitive (however, it's still strongly recommended to learn how to use a terminal editor like `vim` or `emacs`).\n\n`nano myFile.txt`\n\nOnce here, type in some text, then press Ctrl+x to exit the program, then type in `Y` to save the file when you're prompted. Then, `nano` will ask you what file to write to, just press enter to default to `myFile.txt`.\n\nPrint the file again using either `less` or `cat`, and you should see the text you just entered.\n\n### Directories (pwd) :file_folder:\nIn Unix systems, your files are organized in directories. To see the current directory you are working in, use the `pwd` command. It will print a **path** which looks something like:\n\n`/user/azvorygi`\n\nWhat this is saying, is your current working directory is:\n - The \"root\" `/` directory. This is the root of your file system.\n - Which contains the directory `user/`\n - Which contains the directory `azvorygi/`, which is where you currently are. `azvorygi` is my username, so you'll probably see something different.\n \n### Creating a folder (mkdir) :open_file_folder:\nLet's create a folder. The command for this is `mkdir`.\n\n`mkdir my-folder`\n\n\u003e :thought_balloon: Files in Unix systems can contains, dots, dashes, or even emoji 😃!. You can even have spaces, but that's [a little more complicated](https://www.hecticgeek.com/2014/02/spaces-file-names-command-line/).\n\nNow, lets check the contents of our current directory. Try to remember the command to do that. If you don't remember, it's `ls`.\n\nYou should see somewhere in the output of `ls` your new folder.\n\n### Copying and renaming files (cp, mv) :truck:\nLet's copy `myFile.txt` to `my-folder`. To do that we use the `cp` (copy) command. \n\n`cp` takes some arguments, some source files, and a destination. Our source file is `myFile.txt`, our destination is `my-folder`. Altogether:\n\n`cp myFile.txt my-folder`\n\nAs before, there should be no output if the command succeeded as expected, and otherwise it will print out some errors.\n\nNow, let's do a more advanced use of `ls`. Try using the command `ls my-folder`. This should list the contents of the `my-folder` directory. Also notice if you just use the `ls` command without specifying `my-folder`, `myFile.txt` is still present in the current directory.\n\nTo move a file, use `mv` (move), it works much the same as `cp`, except it deletes the original copy of the file. Note, you can use `mv` to rename a file: `mv oldFileName newFileName`.\n\n### Changing directories (cd) :airplane:\nLets go to this new folder we created. The command for that is `cd` (change directory).\n\n`cd my-folder`.\n\nIf you use `pwd`, you should see your working directory has changed to the new directory (something like `/user/azvorygi/my-folder`. If you use `ls`, you should see just the file `myFile.txt`. \n\nLets go back to your home directory now. But instead of doing `cd /user/azvorygi` lets do `cd ..`. In the terminal, `..` means \"go up one directory\". So if you wanted to go up two directories, you could write `cd ../..`. Alternatively, you could write `cd ~` to go back to your home directory. \n\n\u003e :thought:balloon: Remember that `~` refers to your home directory in the terminal.\n\n### Deleting directories and files (rm, rmdir) :\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvory%2Funix-101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzvory%2Funix-101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvory%2Funix-101/lists"}