Learn Enough Command Line 3,4

which locates path of file

curl “client URL”, used to access URl, can be used to download files
-O -L -C saves output as filename indicated by URL, follow location redirects, continues (resumes) previous file transfer

!! repeats last command

!e repeats last command that starts with ‘e’, ‘echo “foo”‘ in this example

^R repeats a command by searching

-h displays bytes in human-readable format (eg: 210=1024 bytes=1KB)

head shows first 10 lines of file

tail shows last 10 lines of file

wc shows lines, words, and bytes

$ head sonnets.txt | wc piping the results of head through wc

less more interactive version of more
Gmoves to end 1G moves to beginning, where 1 represents line (eg: 3G moves to 3rd line)
/ searches file for string (eg: /rose)
n or N next or previous
q quit

grepglobal search for regex and print”
-i ignore case
-v inverse search

ps shows processes
top shows processes, sorted

history shows history of commands

sudo uses superuser permission to execute commands

mkdir make directory

ls -d list directories

pwd print working directory

cd change directory (defaults to home)
.. parent directory
. current directory
~ home directory
- previous directory

find . -name '*.txt' find in current directory and sub-directories all txt files

; runs commands in sequence (eg: ./configure ; make ; make install)

&& runs commands in sequence only if previous command succeeds

 cp -r ../text_files . copy recursively text_files folder and files into current directory

cp -r ../text_files/ . copy only the files

rm -rf second_directory/ instead of rmdir recursively force remove directory and files

Leave a comment

Design a site like this with WordPress.com
Get started