๐๐๐ง๐ข๐ฉ๐ฎ๐ฅ๐๐ญ๐ข๐ง๐ ๐๐ข๐ฅ๐๐ฌ ๐๐ง๐ ๐๐ข๐ซ๐๐๐ญ๐จ๐ซ๐ข๐๐ฌ
- Wildcards:
Wildcards | Meaning |
---|---|
* |
Matches any character |
? |
Matches any single character |
[characters] |
Matches any character that is a member of the set characters |
[!characters] |
Matches any character that is not a member of the set characters |
[:class:]] |
Matches any character that is member of the specified class |
- List of most commonly used character classes
Character class | Meaning |
---|---|
[:alnum:] |
Matches any alphanumeric character |
[:alpha:] |
Matches any alphabetic characters |
[:digit:] |
Matches any numerical |
[:lower:] |
Matches any lowercase letter |
[:upper:] |
Matches any uppercase |
- Wildcard examples:
Pattern | Matches |
---|---|
* |
All files |
g* |
Any file beginning with g |
b*.txt |
Any file beginning with b followed by any characters and ending with .txt |
Data??? |
Any file beginning with Data followed by exactly three characters |
[abc]* |
Any file beginning with either an a, a b, or a c |
BACKUP.[0-9][0-9][0-9] |
Any file beginning with BACKUP. followed by exactly three numerals |
[[:upper:]]* |
Any file beginning with an uppercase letter |
[![:digit:]]* |
Any file not beginning with a numeral |
*[[:lower:]123] |
Any file ending with a lowercase letter or the numerals 1, 2, or 3 |
Wildcards can be used with any command that accepts filenames as arguments
mkdir
โ make directorymkdir dir
โ single directorymkdir dir1 dir2 dir3
โ multiple directories
โโโ(darshanใฟkali)-[~/Desktop/practise]
โโ$ mkdir commandline
โโโ(darshanใฟkali)-[~/Desktop/practise]
โโ$ ls
commandline TryHackMe
โโโ(darshanใฟkali)-[~/Desktop/practise/commandline]
โโ$ mkdir dir1 dir2 dir3
โโโ(darshanใฟkali)-[~/Desktop/practise/commandline]
โโ$ ls
dir1 dir2 dir3
cp
โ copy files and directoriescp item1 item2
: copy single file item1 into item2cp item... directory
: copies multiple items (either files or directories) into a directory.
Option | Meaning |
---|---|
-a ,--archive |
Copy the files and directories and all of their attributes, including ownerships and permissions. |
-i , --interactive |
Before overwriting an existing file, prompt the user for confirmation. |
-r , --recursive |
Recursively copy directories and their contents. This option (or the -a option) is required when copying directories. |
-u , --update |
When copying files from one directory to another, only copy files that either donโt exist or are newer than the existing corresponding files in the destination directory. This is useful when copying large numbers of files as it skips files that donโt need to be copied |
-v , --verbose |
Display informative messages as the copy is performed. |
mv
is same ascp
rm file
: remove files and directoriesrm -rf file
: remove entire directory in one command
Option | Meaning |
---|---|
-i , --interactive |
Before deleting an existing file, prompt the user for confirmation. |
-r , --recursive |
Recursively delete directories. This means that if a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified. |
-f , --force |
Ignore nonexistent files and do not prompt. This overrides the โinteractive option. |
-v , --verbose |
Display informative messages as the deletion is performed. |
ln
: create linksln file link
: create a hard linkln -s item link
: creates a symbolic link
Tags: mkdir, files, folders, bash, mv, rm, cp, cheatsheet, Linux Commands, Linux Command Line, cheat sheet, linux-commands, shell, SSH, bash