Vault/linux/commands.md
2025-05-02 08:43:37 +08:00

1.5 KiB

#Basic Commands ##mv Moves file from one location to another

mv {current file destination} {resulting file destination}

You can use it to rename files as well, by redefining the name in the command

mv {current file name} {new file name}

Move and rename is also possible

mv {current file name} {new file destination/new file name}

##cp Duplicates the file from one location to another

cp {current file destination} {new file destination}

##mkdir makes a new folder with the name

mkdir {folder name}

##rm rm removes files

rm {file name}

rm -r recursively deletes everything within the directory

rm -r {directory}

rm -f forcefully deletes regardless of permissions

rm -f {file}

rmdir deletes directory, like rm -r

rmdir{directory}

##touch updates the last edited/viewed of a file

touch {file}

can also be used to create a new file quickly

##cat need to update

can be used to create a new file quickly, and quickly add content

cat {new file} enter content ctrl-d to save and continue

##&& chain multiple commands mkdir folder && cd folder

##$_ represents the last argument used in a previous command mkdir folder && cd $_

#Bash Features ##brace expansion able to duplicate commands with differing arguments via string formatting

touch file{1,2,3}.txt creates 3 files

mv ./file{,.bak} moves ./file to ./file.bak

rm file{1,2,3}.txt

It is also able to do nested range, touch file{1,2}{a,b}.txt creates file1a.txt file1b.txt file2a.txt file2b.txt