GithubHelp home page GithubHelp logo

terminalprointhebatcave's Introduction

HOW TO BE A TERMINAL PRO - 100 COMMANDS TO KNOW https://code.tutsplus.com/courses/how-to-be-a-terminal-pro and https://code.tutsplus.com/courses/advanced-command-line-techniques

In the SHELL:

hello terminal

  1. echo "hello world" or with with options echo -n "hello world"
  2. ctrl a and ctrl e (start and end of line)
  3. Up key for previous command
  4. !! for repeating previous command
  5. tab and double tab
  6. ~ (home directory)
  7. clear
  8. man echo (manual for each command)

navigation

  1. pwd (print working directory)
  2. cd .. and cd folder (clear directory)
  3. ls directory1 directory2 or ls -lat (list, all, time)
  4. open . (open current directory)
  5. open -a "Sublime Text 2" beans.txt (open beans.txt with application sublime)
  6. open http:aljazeera.com/interactive (open website)
  7. "file name" or file\ name (escaping spaces)
  8. Drag file into terminal for path (super useful)
  9. open -R file.txt (reveal)
  10. killall Finder (reopen filder)

make copy move

  1. touch anewfile.txt (make a new file) or touch directory/anewfile.txt (make a new file in this directory)
  2. nano afile or vim afile or vi afile
  3. mkdir newdirectory
  4. cp beans1.txt beans2.bak (copy a backup) or cp -r beans1 beans2 (copy recursive)
  5. mv afile adirectory (rename a file) or mv afile adirectory/afilenew (move a file to a new directory)
  6. mv file* adir/ (globbing)
  7. cat anewfile.txt (view the contents)
  8. rm santa.txt (remove it) or rm -r santa (remove and remove recursive)
  9. rmdir (delete a directory) could also use rm -r (to delete a folder)
  10. ln -s beans1 beans2 (soft symbolic link to point to another)
  11. ln beans1 beans2 (hard shortcut link)

Revision up to here 28 Feb 2018

finding files and text in files

  1. find . -name "*.txt" (search current directory)
  2. find . -type f (find all the files)
  3. find . -iname "beans" (case insensitive file)
  4. find . -size +2048 (1mb size files)
  5. find . -mtime -1 (-atime -ctime) (modified, access, created)
  6. find . -iname ".txt" -or -iname ".doc" -and mtime -1 (.doc or .txt file last modifiend one day ago)
  7. find . -prune -print (only find direct children)
  8. grep "hello" afile.txt (shows you which line in the code)
  9. grep -ilr "hello" * (find all "hellos") (-i case insensitive -l just the files -r recursively)
  10. find . -name "*.txt" -exec grep -il "Hello" {} ; (grep and find at the same time)

finding files and text in files

  1. -rw-r--r-- js staff - file, user, group, anyone else
  2. drwxrwxrwx (everyone has access to read, write and execute on the directory)
  3. chmod u+w (user) or chmod g+w (group) or chmod o+w (others) or chmod a+w(anyone)
  4. chmod og-x afile.txt (take execution rights from othrs and from the group)
  5. chmod u=rw,g=r,o=, text.txt (user can rw, group can r, others can do nothing)
  6. chmod 644 text.txt (444 is equal to read for everyone)(4 read, 2 write, 1 execute)(700 user can do everything everyone else nothing)

editing file

  1. Nano poem.txt (arrow keys, control k to cut, control u to paste, control o to save file, control x to exit)
  2. vim index.php (normal mode or insert mode)
  3. vim NORMAL MODE (beginning gg) (shift curly brace - moves to the end of paragraph) (^ beginning of line or $ end of line) (shift colon - :set number, :syntax on, :5 (line 5), :) (shift o or shift O add a new line) (shift s - wipe out lines) (shift r - replace text) (dd - delete) (p - paste) (yy - copy) (%s/print/echo/g) (up and down arrows in :) (:w newname.php) (:wq)
  4. vim INSERT MODE (you escape with esc) (u - undo ) (ctrl r - redo)
  5. vim ~/.rc (type in set number, syntax on, set ignorecase)

making tar

  1. MAKING TAR FILES
    1. tar -zxvf nameoftar.tar.gz (unzip)
    2. cd nameoftar (open)
    3. ./configure (dot slash configure)
    4. make (make the files)
    5. make install (make install the files)
    6. nameoftar --version (now check it worked)

piping-redirecting-output

  1. echo "hello world" > afile.txt (append to a file >>)
  2. ls fakefile 2> log (save to a log)
  3. ls documents >> log 2>&1
  4. translate tr a e
  5. tr a e < afile.txt (replace all a's with e's in this file)
  6. PIPING - ls -a | grep "." (only find hidden files and directories)

managing processes

  1. top (sample of processes on your mac)(exit with q)
  2. top -o cpu (order by CPU usage)
  3. ps -cvx (c- name, x- owned by user, v- other info)(process statuses)
  4. ps -cvx | grep "Google" (finds all Google processes)
  5. term 35157 (quits Google Chrome)
  6. kill -s KILL 35178 (force quits)

ssh keygens

  1. ssh-keygen -t rsa (creates id_rsa, id_rsa.pub, known hosts)
  2. scp id_rsa.pub [email protected]:~/.ssh/authorized_keys (securely copy to the remote server)
  3. login user2
  4. (dont' overwrite the pubkey) cat id_rsa.pub |ssh [email protected] "cat >> ~/.ssh/authorized_keys"
  5. SSH host alias (cd .ssh, nano config, Host server, Hostname 10.1.1.1, User Haddad)

sftp scp curl

  1. scp file1.txt server:~/remote
  2. sftp server
  3. lpwd (locally print out my working directory)
  4. put file1.txt
  5. get random.txt (exit or quit)
  6. curl (supports many protocols)(scrapes web pages or get files)
  7. curl http://aljazeera.com > afile.html
  8. curl -Of http://aljazeera.com (fail silently)

bash scripting

  1. nano .bash_profile - function helloworld(){ echo "hello, $1"}
  2. SHELL SCRIPTS - nano newSite.sh (#!/bin/bash) (chmod +x newSite.sh)(./newSite.sh someexample)
  3. sudo cp /usr/local/bin (super user do)
  4. echo $PATH
  5. alias runthis="ssh [email protected]"

terminalprointhebatcave's People

Contributors

megomars avatar

Stargazers

Kobi Kai Calev avatar

Watchers

James Cloos avatar  avatar

Forkers

ajinteractive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.