_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

command_line_introbasic commands

Move file or directory : mv SOURCE TARGET
Copy file : cp SOURCE TARGET
Copy direcotry : cp -r SOURCE TARGET
Remove file : rm FILENAME
Remove directory : rm -r DIRECTORY

The flag -R/-r applies to different commands to execute recursive actions.

back to top

head : Get the first 10 lines of a file : head FILENAME
head -15 : Get the first 15 lines of a file : head -15 FILENAME
tail : Get the last 10 lines of a file : tail FILENAME
tail -15 : Get the last 15 lines of a file : tail -15 FILENAME
tail -f : Get the latest lines of a file continuously : tail -f FILENAME

Get lines matching pattern : grep PATTERN FILE(S)
Get lines not matching pattern : grep -v PATTERN FILE(S)
Get file names not matching pattern : grep -L PATTERN FILE(S)
Get line numbers matching pattern : grep -n PATTERN FILE(S)
Perform a case-insensitive search for pattern : grep -i PATTERN FILE(S)
Perform a recursive search : grep -R PATTERN DIRECTORY

back to top

Get network information using ifconfig (part of the package net-tools which may need to be installed) or ip.

sudo ifconfig -a
sudo ip add

back to top

Command output can be redirected to other commands using | .

-n : Maximum number of arguments.
-0 : User NUL as separator instead of the default space and newlines.
$ echo -e "1\n2\n3" | xargs -n1 echo
1
2
3
$ echo -e "1\n2\n3" | xargs echo
1 2 3
$ echo -e "1\n2\n3" | xargs -0 echo
1
2
3

$ echo "1 2 3" | xargs echo
1 2 3
$ echo "1 2 3" | xargs -n1 echo
1
2
3

back to top

text_manipulation , linux

- Archlinux manpages: mv(1) , cp(1) , rm(1) , tail(1) , head(1) , ifconfig(8) , ip(8) , xargs(1) , grep(1)

back to top

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: linux , OpenBSD 7.8 | Created:2026-03-27|Updated:2026-03-27|