User Tools

Site Tools


linux:working-in-the-shell

Working in the shell

Date: Wed Sep 26 17:51:57 EDT 2018

File basics

  • ls : list directory contents
  • cp : copy files and directories
  • mv : move (rename) files
  • rm : remove files or directories
  • shred : overwrite a file to hide its contents, and optionally delete it
  • ln : make links between files

Directory basics

  • cd : change the shell working directory
  • pwd : print name of current/working directory
  • basename : strip directory and suffix from filenames
  • dirname : strip last component from file name
  • mkdir : create a directory
  • rmdir : remove empty directories

View Files

  • cat : concatenate files and print on the standard output
  • tac : concatenate and print files in reverse
  • less : opposite of more
  • more : file perusal filter for crt viewing
  • head : output the first part of files
  • tail : output the last part of files
  • nl : number lines of files
  • od : dump files in octal and other formats
  • xxd : make a hexdump or do the reverse
  • comm : compare two sorted files line by line
  • cmp : copmare two files byte by byte
  • diff : compare files line by line
  • sdiff : side-by-side merge of file differences
  • diff3 : compare three files line by line

Vie file properties

  • stat : get file status
  • wc : print newline, word, and byte counts for each ffile
  • du : estimate file space usage
  • file : determine file type
  • touch : change file timestamps

Modify file properties

  • chown : change file owner and group
  • chgrp : change group ownership
  • chmod : change file mode bits
  • chattr : change file attributes on a Linux file system

Locate files

  • find : search for files in a directory hierarchy
  • locate : find files by name
  • which : locate a command
  • apropos : search the manual page names and descriptions
  • type : display informatino about command type
  • whereis : locate the binary, source, and manual pages files for a command

Manipulate files, fields, and characters

  • grep : print lines matching a pattern
  • sort : sort lines of text files
  • uniq : report or omit repeated lines
  • tee : read from standard input and write to standard output and files
  • cut : remove sections from each line of files
  • paste : merge lines of files
  • join : join lines of two files on a common field
  • tr : translate or delete characters
  • expand : convert tabs to spaces
  • unexpand : convert spaces to tabs
  • sed : stream editor for filtering and transforming text
  • awk : pattern scanning and processing language

Compress and/or package files

  • gzip : compress or expand files
  • gunzip : compress or expand files
  • bzip2 or bunzip2: a block-sorting file compressor
  • zip : package and compress (archive) files
  • unzip : list, test and extract compressed files in a ZIP archive
  • tar : an archiving utility

Examine disk usage and filesystems

  • df : report file system disk space usage
  • mount : mount filesystem
  • umount : unmount filesystem
  • udisksctl : The udisks command line tool
  • fsck : check and repair a Linux filesystem
  • lsblk : list block devices

Check spelling

  • look : display lines beginning with a given string
  • aspell : interactive spell checker

Viewg and control running processes

  • ps : report a snapshot of the current processes
  • pgrep or pkill : look up or signal processes based on name and other attributes
  • pstree : display a tree of processes
  • top : display Linux processes
  • htop : interactive process viewer
  • journalctl : Query the systemd journal
  • systmed-cgls : Recursively show control group contents
  • uptime : Tell how long the system has been running
  • free : Display amount of free and used memory in the system
  • kill : send a signal to a process
  • nice : run a program with modified scheduling priority
  • renice : alter priority of running processes

Output to screen

  • echo : display a line of text
  • printf : format and print data
  • seq : print a sequence of numbers
  • clear : clear the terminal screen

Do math

  • expr : evaluate expressions
  • dc : an arbitrary precision calculator
  • bc : An arbitrary precision calculator language

Date and time utilities

  • cal or ncal : displays a calendar and teh date of Easter
  • date : print or set the system date and time

Schedule jobs

  • sleep : delay for a specified amount of time
  • watch : execute a program periodically, showing output full screen
  • crontab : maintain crontab files for individual users

Others to address

  • wget : The non-interactive network downloader
linux/working-in-the-shell.txt · Last modified: 2019/01/21 11:15 by seanburns