Skip to content
Ben Casalino edited this page May 23, 2018 · 1 revision

CLI TERMINAL CONSOLE etc...

CLI/Git/Version Control Terminal/Shell/Console: Terminal/Shell/Bash/TTY/Console: Terminal = tty (teletypewriter) = text input/output environment ← A terminal refers to a wrapper program which runs a shell.

A terminal was also originally hardware, used to communicate with a computer. Nowadays it usually refers to a window with a command line (shell), which might appear in a GUI window or instead of a GUI.

Console = physical terminal ← The console is a special sort of terminal. Interacting with the console is also done using a shell program.

A console was originally a physical thing, a control panel. In computing terms it usually means the display that you see before the GUI starts up or after it finishes; you can sometimes switch to displaying it instead of the GUI. It's the place where the operating system prints error messages. On a multi-user computer, it's the display that's actually attached to the computer. 

Shell = command line interpreter → The shell is the program which actually processes commands and returns output. Most shells also manage foreground and background processes, command history and command line editing. These features (and many more) are standard in bash.

A shell is a program that puts up a prompt and waits for you to type commands. It executes them and then prints another prompt. So, like CMD in Windows, or Bash in Unix. It can run in a terminal or on the console.

Bash = the most common shell in modern linux systems.

Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh is an extended Bourne shell with a large number of improvements, including some features of Bash, ksh, and tcsh.

Oh My Zsh: is an open source, community-driven framework for managing your ZSH configuration.

Curl is a command line tool for making requests over HTTP(s), FTP and dozens of other protocols you may have not heard about. It can download files, check response headers, and freely access remote data. In web development curl is often used for testing connections and working with RESTful APIs.

Tree is a tiny command line utility that shows you a visual representation of the files in a directory. It works recursively, going over each level of nesting and drawing a formatted tree of all the contents. This way you can quickly glance over and find the files you are looking for. → tree -P '.min.' ← would show just the minified files

Disk usage - du The du command generates reports on the space usage of files and directories. It is very easy to use and can work recursively, going through each subdirectory and returning the individual size of every file.

SSH → With the ssh command users can quickly connect to a remote host and log into its Unix shell. This makes it possible to conveniently issue commands on the server directly from your local machine's terminal. There is a lot you can do with SSH like creating proxies and tunnels, securing your connection with private keys, transferring files and more.

Cat and Less → Less is a much better way to inspect large files on the command line. You’ll get a screen-full of text at a time, but no more. You can move a line up or a line down with the k and j respectively, and move a window up or down with b and f. You can search for a pattern by typing /pattern. When you’re done, hit q to exit the less viewer.

Tar and Gzip → two form of file compression. Can be downloaded/unzipped via the command line.

NPM : node(js) package manager

Homebrew:is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system.

Sudo: you can use the sudo (super user do) command to give you root permissions for a single command. You’ll be asked for you user account password, and when you’re provided that, the system will execute the command.

CHMOD/ CHOWN → change/modify file permissions. There are three permissions you can set, and there are three classes that can receive those permissions. The permissions are read, write, and execute; the classes are user, group, and others.

Man & --help → to see the manuals, or man pages, as they’re called. Just type man followed by the command you’re curious about. Ex. man chown← item to look up more details about

Git/Github: Resources: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
https://git-scm.com/book/en/v2/Git-Branching-Rebasing https://stackoverflow.com/questions/2472254/when-should-i-use-git-pull-rebase/4675513#4675513
https://help.github.com/articles/resolving-merge-conflicts-after-a-git-rebase/

Git Workflows: https://www.atlassian.com/git/tutorials/comparing-workflows

Rewrite history and remove the old files - LOLA ? ← update this section

Replace FILE_LIST with the files or directories that you are removing... git filter-branch --tag-name-filter cat --index-filter ‘git rm -r --cached --ignore-unmatch FILE_LIST’ --prune-empty -f -- --all git push origin --force --all

Centralized Workflow - added as a collab

  1. Make sure that both partners have the ability to push directly to your main repository.
  2. All changes are pushed to Master directly.

Contributor Forking

  1. The partner who owns the repository does not give their partner any permissions for the repository. ~ 2. To work on the code, their partner must fork and clone the repository.
  2. When their partner wants to push changes to Github they must push the changes to their forked repository and submit a pull request.
  3. The partner who owns the repository must accept the pull request to have the changed merged into the master repository.

Feature Branching

  1. Make sure that both partners have the ability to push directly to your main repository.
  2. For each task create a well named feature branch to commit your changes.
  3. When the changes are done and working the branch is merged into master.

Branch and Pull Request

  1. Make sure that both partners have the ability to push directly to your main repository.
  2. For each change create a well named feature branch to commit your changes.
  3. Push your branch to the remote repository and then make a pull request to have it merged in.
  4. Your partner should be the one to merge the pull request.

Git Merge Conflicts:

Git merge “ my branch” will open a text editor(nano) to confirm/ and close.

Git Upstream:

Git Set-URL:

Git “HEAD”: You can think of the HEAD as the "current branch". When you switch branches with git checkout, the HEAD revision changes to point to the tip of the new branch. A head is simply a reference to a commit object. Each head has a name (branch name or tag name, etc). By default, there is a head in every repository called master. A repository can contain any number of heads. At any given time, one head is selected as the “current head.” This head is aliased to HEAD, always in capitals".

Note this difference: a “head” (lowercase) refers to any one of the named heads in the repository; “HEAD” (uppercase) refers exclusively to the currently active head. This distinction is used frequently in Git documentation.

Represents “where” or what version/branch you are on.

CLI Navigation: Renaming or Moving Folders with the mv command

The mv command can act as a tool to rename or move folders. A rename is essentially a move.

$ mv folder-name new-folder-name

The first argument is the current folder location. The second is the destination for the folder. Each of these arguments are paths to the folders from your current directly. Make sure you understand how paths work when using the mv command.There are some caveats to the mv command when renaming to a location that previously exists.

Renaming or Moving Files with the mv command

Using the mv command we can rename or move files. A rename and move performed in the same manner.

$ mv filename.txt new_filename.txt

The first argument is the current file location. The second is the destination for the file. Each of these arguments are paths to the files from your current directly. Make sure you understand how paths work when using the mv command.A move would look the same but probably include a path to another folder.

$ mv filename.txt ../filename.txt

Deleting Folders with the rm command

Deleting a folder can be completed with the rm command. When deleting a folder, we will also be deleting all items inside of it (if any exist). For the command line to know we are intending to remove all contents as well, we need to include -rf:

$ rm -rf folder-name The -rf means recursive and force. Recursive includes all child folders. Force allows us to remove a directory with files inside of it. Note: This command won't confirm before performing the action. Make sure you have your paths correct!!

Deleting Files with the rm command

Deleting a file is a simple command:

$ rm filename.txt

We can also remove multiple files at once:

$ rm filename.txt filename2.txt

Note: This command won't confirm before performing the action. Make sure you have your paths correct!!

Copying Files and Folders

To copy files, we use the cp command. For files, it's a simple:

$ cp file1.txt file2.txt

file1.txt is the source. file2.txt is the destination.

If we want to copy folders, we need to pass the recursive flag -r, or we will see errors:

$ cp foldername foldername2

Hidden files and directories Hidden files and directories scattered throughout your computer's operating system. All it takes to hide a file or directory is to start its name with a period . prefix. Many programs have configuration settings that they want stored out of plain sight from users. Traditionally, these settings are stored in hidden files and directories in your home directory.Hidden items can be revealed by using the -a flag with the ls command. ls -a or lsa

Clone this wiki locally