๐Œ๐š๐ง๐ข๐ฉ๐ฎ๐ฅ๐š๐ญ๐ข๐ง๐  ๐Ÿ๐ข๐ฅ๐ž๐ฌ ๐š๐ง๐ ๐๐ข๐ซ๐ž๐œ๐ญ๐จ๐ซ๐ข๐ž๐ฌ

  • 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 directory
    • mkdir dir – single directory
    • mkdir 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 directories
    • cp item1 item2 : copy single file item1 into item2
    • cp 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 as cp

  • rm file : remove files and directories
  • rm -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 links
    • ln file link : create a hard link
    • ln -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

MIT license