What is the head command on Linux

Linux commands

Output files

Output files one after the other: cat
Output file page by page: more, less
Output the first lines of a file: head
Output file from a certain line: tail
Output file with line numbers: nl
Output file octal / hexadecimal: od, hd

List and analyze files

List files: ls
List file attributes: lsattr
Determine file type: file
Get program file from command: type
Counting characters, words and lines: wc
Determine the checksum for a file: sum, md5sum, sha1sum
Show which process opened a file or socket: fuser
Show open files: lsof
Copy, rename and delete files
Copy files: cp
Renaming / moving files: mv
Set link to file: ln
Delete files or directory trees: rm

Search

Search for files: find
Find files quickly: locate, slocate
Update locate database: updatedb
Search in files: grep, fgrep, egrep
Show the full path of a command: which
Display path to program file, source file and man file: whereis

Compare, merge and sort files

Compare two text files: diff
Compare sorted text files: comm
Compare two files: cmp
Merging files: join
Sort files: sort

Compress and archive files

(De-) compressing files: gzip / gunzip, pack / unpack, compress / uncompress, arc, unarj, unrar
(De-) compressing files with bzip: bzip2, bunzip2, bzcat

Display contents of gzip archives: zcat, zless, zmore
Archiving or copying files and file trees: tar, cpio

Change access rights, owner and time stamp

Change access rights of a file: chmod
Changing the owner of a file: chown
Change the group of a file: chgrp
Change attributes of a file: chattr
Set or output file creation mask: umask
Change the timestamp of a file: touch

Reshaping, extracting and dividing files

Replace characters in files: tr
Transform strings: sed
Convert tabs to spaces: expand
Convert fonts: recode, iconv
Output identical, consecutive lines only once: uniq
Cutting out columns or fields from files: cut
Splitting files: split, csplit

To press

Output file to printer: lp, lpr
Request status information on print jobs: lpstat, lpq
Cancel print jobs: cancel
Manage printers: lpc
Delete print jobs: lprm

Device and FIFO files

Creation of device files or named pipes: mknod
Creation of FIFO files: mkfifo

Directories

Output current directory: pwd
Change to a directory: cd
Create a directory: mkdir
Delete a directory: rmdir, rm
Compare two directories: diff
Base name of a path: basename
Directory name of a path: dirname

Storage information

Determine free storage space: df
Determine the storage requirements of files or directories: du
Display of the free main memory and swap: free

File systems

Mount, partition, format and copy
Mounting a filesystem: mount
Unmounting a file system: umount
Partitioning a hard drive: fdisk, cfdisk
Create, reduce, enlarge and move partitions: parted
Format floppy disks: fdformat
Copying and converting file systems and partitions: dd
Setting up file systems: mkfs
Creating an ext2 or ext3 file system: mke2fs
Create ReiserFS file system: mkreiserfs
Set up swap partitions and files: mkswap, swapon, swapoff
Checking and repairing a file system: fsck
Physical check of a data carrier: badblocks
Information on an ext2 / ext3 file system: dumpe2fs
Change system parameters of an ext2 / ext3 file system: tune2fs
Write buffered data to the hard disk: sync
Access to MS-DOS floppy disks: mtools

Users and Groups

Create user: useradd, adduser
Change user properties: usermod
Set / show the expiry date of the password: chage
Change password: passwd
Delete user: userdel
Find out your own login name: logname, whoami
Find the user and group ID: id
Create group: groupadd
Change group name or ID: groupmod
Delete group: groupdel
Output of the group memberships of a user: groups
Change active group: newgrp

Show registered users: who, w
Send a message to logged in users: wall
Show last logins: last, lastlog
End a session: logout, exit

Process management

Output of information about processes: ps
Output of the process hierarchy: pstree
List the processes according to CPU load: top
Perform time measurements of processes: time
Sending signals to processes: kill, killall
End process under X: xkill
Start processes in the background: &
List of stopped processes or background processes: jobs
End process in the foreground: [Ctrl] + C
Stop the process in the foreground: [Ctrl] + Z
Continuing a process in the background: bg
Continuing a process in the foreground: fg
Run programs periodically: cron, crontab
Run the program periodically and display the output: watch
Run programs at a specific point in time: at
Execute commands sometime later: batch
Let processes continue after the session ends: nohup
Put the process to sleep: sleep

Run programs as a different user

Change user ID without logging in: see below
Run as a different user: sudo
Change process priorities Let processes run with a different priority: nice
Change the priority of running processes: renice

system

System shutdown: shutdown
Restart the system: reboot
End all processes: stop
Show runlevel: runlevel
Change runlevel: init
Show boot messages: dmesg
Output system information: uname
Show time since system start and average load: uptime

hardware

Display PCI devices: lspci
Set hard drive parameters: hdparm
Query and set date and time: date
Set hardware clock: hwclock
Calendar: cal

network

Testing connections: ping
Display or change your own host name: hostname
Determine host name or IP: host
Configure network interface: ifconfig
Establish and clear network connection: ifup, ifdown
Show network connections: netstat
Path of a packet through the network: tracerouteFTP, Secure Shell
Transferring files from or to another computer: ftp
Download files via http or ftp: wget
Log on to another computer with a secure shell: ssh
Safe copying of files over the network: scp

Screen and terminal

Setting and querying terminal settings: stty
Changing terminal settings: setterm
Restore the terminal character set: reset
Clear screen: clear
Requesting the terminal name: tty
Change terminal: [Alt] + [F1 to Fn]
Change terminal from X: [Ctrl] + [Alt] + [F1 to Fn]

Shell

Change login shell: chsh
Show or change environment variables: printenv, set
Export environment variables: export
Assign short name for command: alias
Delete short name from command: unalias
Input and output redirection Redirect output (pipe): |
Branch the output and save it in a file: tee
Read and pass on arguments: xargs
Redirect output to file / append to file:> file, >> file
Redirect error output: 2> file
Input redirection: Reading commands from a file and executing them:. , source
Editors
Edit files: pico, joe, vi (exit: “: q”), emacs
PostScript, converting PostScript and PDF files: gs
Converting text to PostScript: a2pdf, enscript, mpage
Convert PDF to PostScript and vice versa: pdf2ps, ps2pdf
Convert HTML files to PostScript: html2ps
Convert DVI files to PostScript: dvips
Manipulation of PostScript files: psutils

Other commands

Output text: echo
Necessary to run a program
Show shared libraries: ldd
Compiling and Linking C and C ++
Programs: cc, gcc, g ++, make
Encrypt files: gpg
Calculator: bc