UNIX

Terminal logotyp Install script

Förkortningar

  • UNICS - Uniplexed Information and Computing Service

  • POSIX - Portable Operating System Interface for uniX

  • NPM - Node package manager
  • CRT - Cathode ray tube
  • MC - Midnight Commander

  • csh - C shell
  • ksh - Korn shell
  • sh - Bourne shell

  • SED - stream editor
  • AWK - Aho, Weinberger, and Kernighan
  • RC - runcom

  • SIP - System Integrity Protection

Filändelser

  • .sh
Oh my Zsh

Citat

Write failed: Broken pipe
You have mail.

Kortkommandon för UNIX

  • Tab ? : Autocompletes from the cursor position.
  • Ctrl+a : Moves the cursor to the line start (equivalent to the key Home).
  • Ctrl+b : Moves the cursor back one character (equivalent to the key ?).
  • Ctrl+c : Sends the signal SIGINT to the current task, which aborts and closes it.
  • Ctrl+e : (end) moves the cursor to the line end (equivalent to the key End).
  • Ctrl+f : Moves the cursor forward one character (equivalent to the key ?).
  • Ctrl+h : Deletes the previous character (same as backspace).
  • Ctrl+i : Equivalent to the tab key.
  • Ctrl+j : Equivalent to the enter key.
  • Ctrl+k : Clears the line content after the cursor and copies it into the clipboard.
  • Ctrl+l : Clears the screen content (equivalent to the command clear).
  • Ctrl+n : (next) recalls the next command (equivalent to the key ?).
  • Ctrl+p : (previous) recalls the prior command (equivalent to the key ?).
  • Ctrl+r : (reverse search) recalls the last command including the specified character(s). A second Ctrl+r recalls the next anterior command that corresponds to the search
  • Ctrl+t : Transpose the previous two characters.
  • Ctrl+u : Clears the line content before the cursor and copies it into the clipboard.
  • Ctrl+w : Clears the word before the cursor and copies it into the clipboard.
  • Ctrl+y : (yank) adds the clipboard content from the cursor position.
  • Ctrl+z : Sends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter bg. To bring it back from background or suspension fg ['process name or job id'] (foreground) can be issued.

  • Ctrl+_ : Incremental undo, separately remembered for each line.

Termination Signals

  • SIGTERM
  • SIGINT
  • SIGKILL
  • SIGHUP

Filer

  • .aliases
  • .bash_aliases
  • .bash_history
  • .bash_profile
  • .bashrc

ASCII art

__ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ Cathode

Program

Program

Öppna nuvarande mapp

open .

Upplösning för .png

file *

Skapa symlänk

ln -s /Applications/MAMP/htdocs/ htdocs

Byt lösenord

passwd [username] Changing local password for [username] New Password: Retype New Password:

Tid

date +"%H:%M:%S"

Tid i millisekunder

date +%s

Tid för användare

time

Ladda om fil

tail -f fil

Öppna en fil med ett program

open -a Program "fil"

Flytta dolda filer

mv .* ../

Avsluta ett program

killall program

Status för en fil

stat file

Manual

man command

Hjälp

help

Starta om bash

source ~/.bash_profile . ~/.bash_profile

Version operativsystem

uname -a

Versionsflagga för program

program --version

List all available commands

compgen -c

Download file

wget -O file example.com/file

Flytta filer till server

scp . user@ip:/folder

Hämta filer från server

scp user@ip:/folder .

Sök på filnamn

find . -name filename

Söka efter ett ord i en specifik fil

cat file.txt | grep Word

Söka efter ett ord

grep "Word" file.txt

Only hidden files

ls -d .*

Sök förutom i en mapp

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search

Files in folders

ls -l | wc -l ls -lA | wc -l

Dölj mappar eller filer

chflags nohidden /path/to/file-or-folder

Visa dolda filer som default i OsX

defaults write com.apple.finder AppleShowAllFiles TRUE

Extrahera .tar.gz

tar -zxvf file.tar.gz

Extrahera .tar

tar -xvf file.tar

Senaste besökare

last -10

Användare

users

Groups

groups

Alias

alias

Grupper

groups /etc/group

Rättigheter

sudo chown -R username:group directory sudo chmod -R XXX directory

Interface

chsh –s /bin/bash user chsh –s /bin/sh user

Historik

~/.bash_history

Töm historik

history -c

Föregående

!!

Kopiera

pbcopy

Klistra in

pbpaste

Personliga filer

~/.bash_profile ~/.bashrc ~/.bash_aliases

History size

HISTFILESIZE=1000000000
HISTSIZE=1000000

Alias

alias ll="ls -la" alias htdocs='cd /Applications/MAMP/htdocs/'

Telnet

telnet towel.blinkenlights.nl telnet mapscii.me

Felmeddelande

urls=('www.domain.com'); for i in ${urls[@]}; do http_code=$(curl -I -s $i -w %{http_code}); echo $i status: ${http_code:9:3}; done

Checking Free Disk Space

df -h df -k du

Grunt

sudo npm install -g grunt-cli sudo npm install grunt build

Jämför

Filer (side by side)

diff -y

Mappar

diff -arq folder1 folder2

Upplösning för PNG

file *

SerienummerMac

ioreg -c "IOPlatformExpertDevice" | awk -F '"' '/IOPlatformSerialNumber/ {print $4}'

Röst

say -v ? Word

How can I calculate the size of a directory?

du -s directory_name

Or to get human readable output

du -sh directory_name

The -s option means that it won't list the size for each subdirectory, only the total size.

Namn på röster

  • Agnes
  • Albert
  • Alex
  • Alice
  • Alva
  • Amelie
  • Anna
  • Bad News
  • Bahh
  • Bells
  • Boing
  • Bruce
  • Bubbles
  • Carmit
  • Cellos
  • Damayanti
  • Daniel
  • Deranged
  • Diego
  • Ellen
  • Fiona
  • Fred
  • Good News
  • Hysterical
  • Ioana
  • Joana
  • Junior
  • Kanya
  • Karen
  • Kathy
  • Kyoko
  • Laura
  • Lekha
  • Luciana
  • Mariska
  • Mei-Jia
  • Melina
  • Milena
  • Moira
  • Monica
  • Nora
  • Paulina
  • Pipe Organ
  • Princess
  • Ralph
  • Samantha
  • Sara
  • Satu
  • Sin-ji
  • Tarik
  • Tessa
  • Thomas
  • Ting-Ting
  • Trinoids
  • Veena
  • Vicki
  • Victoria
  • Whisper
  • Xander
  • Yelda
  • Yuna
  • Zarvox
  • Zosia
  • Zuzana

MySQL

mysqldump -u användarnamn -plösenord databas > filnamn.sql

Rättigheter

  1. No permissions ("---")
  2. Execute only (rare) ("--x")
  3. Write only (rare) ("-w-")
  4. Write and execute (rare) ("-wx")
  5. Read only ("r--")
  6. Read and execute ("r-x")
  7. Read and write ("rw-")
  8. Read, write, and execute ("rwx")
export PATH=$PATH:.

Variabler med beskrivningar

$0
The filename of the current script.
$n
These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on).
$#
The number of arguments supplied to a script.
$*
All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2.
$@
All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2.
$?
The exit status of the last command executed.
$$
The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
$!
The process number of the last background command.

Kommando (och vissa förkortningar)

  • afplay
  • bc
  • cal
  • cd
  • chmod [-R]
  • clear
  • cmp
  • cp
  • curl [-o]
  • date
  • diff
  • ditto
  • drush
  • du
  • echo
  • ftp
  • git
  • help
  • history
  • ifconfig
  • info
  • ls [-a][-l]
  • man
  • mkdir
  • mv
  • mysql
  • nano
  • open
  • pico
  • ping [-c count][-i wait][-t timeout]
  • pwd
  • rm
  • rmdir
  • say [-v voice]
  • scp
  • sleep
  • ssh
  • sudo
  • tail
  • telnet
  • top
  • touch
  • unzip [-d]
  • uptime
  • vim
  • vimtutor
  • wc
  • who
  • who am i
  • whoami

Already have a key?

Copy your key to your clipboard with:

cat ~/.ssh/id_rsa.pub | pbcopy

Change Password over SSH

ssh -t user@server-name-here /bin/passwd

UNIX timestamp med PHP

date('U')

UNIX timestamp med MySQL

UNIX_TIMESTAMP()

How to Disable System Integrity Protection (rootless) in Mac OS X

Status

csrutil status

Disable

csrutil disable

Enable

csrutil enable

Reboot

reboot

USB

lsusb

Replace with sed

sed -i -e 's/search\/replace/g' file Bill Joy Brian Kernighan Dennis Ritchie Ken Thompson

Kända personer

  • Bill Joy
  • Brian Kernighan
  • Dennis Ritchie
  • Ken Thompson
Haskell logotyp

Externa länkar

Default shell for a user

/etc/passwd

Lists all shells installed on the system

cat /etc/shells

Change its default shell

chsh Homebrew (brew.sh) *nix