Skip to content

77-osiris/linux-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Linux CLI Notes

A personal cheat sheet for Linux command line essentials.
Organised by topic, with commands, descriptions, and examples.
Updated as I progress through The Linux Command Line book.


Navigation

  • cd – Change directory

    cd ..         # go up one directory
    cd /etc       # go to /etc
    cd /usr/bin   # go to /usr/bin
    cd ~ 			# go to current users home
    cd ~$USER     # go to specified user home
  • ls – list directories and files

    ls -l   		# long list format
    ls -la  		# include hidden files
    ls -li  		# show inode numbers
  • pwd – print current directory

    pwd 			# prints the current (working) directory

File Control and Manipulation

  • mkdir – create a directory
    mkdir (name)	# creates a new directory with a given name
  • touch – create a file
    touch (name) 	# creates a new file with a given name
  • rm – removes files/directories
    rm (name)    	# deletes files/directories 
  • nano – opens a file in a text editor
    nano (name)  	# opens a file in a text editor. creates one if !file
  • cp – make a copy of a file or directory
    cp src dest  	# copy files/directory 
  • mv – opens a file in a text editor
    mv old new  	# opens a file in a text editor. creates one if !file

Searching

  • find – find a file or directory on the host machine
    find 					# will search for a directory and or File
      Options - find 'dir'
      		- find file 
      		- find dir file 
  • grep – find matching strings
    grep 							# find matching strings in a file or directory name, as well as matching strings in a files content
    grep -i 						# ignore case sensitivity
    grep -r text dir				# search recursively in directory

Linking

  • ln – create a link
    ln link_file link_to_file		 # creates a hard link 
    ln -s /path/target symlink-name		# creates a symbolic link

Output and Redirection

  • > – Redirect stdout to file (overwrite)

    cat /path/target > output.txt
  • >> – Redirect stdout to file (append)

    cat /path/target >> output.txt
  • 2> – Redirect stderr (overwrite)

    cat /path/target 2> errors.txt
  • 2>> – Redirect stderr (append)

    cat /path/target 2>> errors.txt
  • &> – Redirect stdout and stderr (overwrite)

  • | – Pipe output to another command

    cat file | grep string | wc 
  • tee – Write to file and stdout

    cat file | tee | grep string | 

Help & Documentation

  • man – Manual pages

1 = user commands

2 = system calls

3 = C library functions

4 = special files (device nodes, drivers)

5 = file formats

6 = games

7 = misc

8 = admin commands

whatis – One line descriptor

About

Write up of my learning of Linux CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published