Home Linux cp, mv, edit, create commands
Post
Cancel

Linux cp, mv, edit, create commands

Working with files

copy file/folder

1
cp (filename/folder) (directory)

[!Note]- (remember, if the filename/folder name has spaces then you will need to encase the filename with speech marks such as cp “(filename with spaces)” (directory). This applis to other commands such as mv. )

1
cp ssh.conf /home/newfolder 

move file/folder

mv (filename) (directory)

example

1
mv ssh.conf /home/newfolder  

move multiple files/folders simultaneously

mv (file1) (file2) (file3) -t (directory to move to)

example

1
mv logs.txt keys.conf script.py -t /home/savedWork

Move all files from current directory into another directory

mv * (directory to move files to)

example

1
mv * /home/scripts  

rename files/folder

mv (current filename) (new filename)

example

1
mv ssh.conf NewSSH.conf  

create a file

touch (filename)

example

1
touch newFile.txt  

create a folder

mkdir (foldername)

example

1
mkdir newFolder

open file for editing

nano (filename)

example

1
nano keys.conf

output contents of file

cat (filename)

example

1
cat keys.conf  

upload file to a remote machine

scp (filename) (username)@(IP of remote machine ):/(directory to upload to)

example

1
scp example.txt john@192.168.100.123:/home/john/

run an bash script program

./(name of script)

example

1
./timer  

open a file for reading/editing

nano (filename)

example

1
nano readME.txt

More Notes

files/folders with special characters such as - (dash), if you try to copy or move these files you will encounter errors because Linux interprets the - as a type of argument, therefore you will have to place – just before the filename.

example

1
cp -- -filename.txt /home/folderExample.
This post is licensed under CC BY 4.0 by the author.