> For the complete documentation index, see [llms.txt](https://olb.gitbook.io/linux-essentials-certification/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olb.gitbook.io/linux-essentials-certification/2.finding_your_way_on_linux/2.4-creating-moving-deleting-files.md).

# 2.4 CRUD on files and moving

**Weight 2**\
Key knowledge areas

* Files and directories
* Case sensitivity
* Simple globbing

Partial list of the used files, terms and utilities

* mv, cp, rm, touch
* mkdir, rmdir

***

## CRUD on Files

* `mkdir` create directory
* `mkdir -p` create parent directory
* `cd ~` go to home directory
* `touch` create file
* `echo hello > question` add hello into file question
* `mv` move file / add `-i` for asking f overwriting
* `rm` delete file
* `rmdir` delete **empty** directory
* `rm -ri` delete files + directory but ask
* `find` list directory (like ls) or search
* `cp` copy files / add `-r` for directory
* `cp -u` copy file only if destination is missing or older
* `cp -r` copy directory and content recursively
* `cat` read file
* `pwd` output directory path

## Globbing

* `*` Matches any number of any character, including no characters `$ ls star*` `star10 star1100 star2002 star2013`
* `?` Matches any one character `$ ls question1?` `question13 question14 question15`
* `[]` Matches a class of characters
  * `$ ls file[1-2]` `file1 file2`
  * `$ ls file[^a]` `file1 file2`
  * `$ ls file[[:digit:]]` `file1 file2 file3`

The glob `file[[:digit:]a]`, matches file followed by a digit or a.

The character classes supported depends on your current locale. POSIX requires the following character classes for all locales:

* `[:alnum:]` Letters and numbers.
* `[:alpha:]` Upper or lowercase letters.
* `[:blank:]` Spaces and tabs.
* `[:cntrl:]` Control characters, e.g. backspace, bell, NAK, escape.
* `[:digit:]` Numerals (0123456789).
* `[:graph:]` Graphic characters (all characters except ctrl and the space character)
* `[:lower:]` Lowercase letters (a-z).
* `[:print:]` Printable characters (alnum, punct, and the space character).
* `[:punct:]` Punctuation characters, i.e. !, &, ".
* `[:space:]` Whitespace characters, e.g. tabs, spaces, newlines.
* `[:upper:]` Uppercase letters (A-Z).
* `[:xdigit:]` Hexadecimal numerals (usually 0123456789abcdefABCDEF).
