Basic file and folder manipulation with linux

 

 

Here are some simple file and folder manipulation commands for more information check out the man pages in your linux distribution.

Be careful when manipulating files in Linux because linux will allow you to remove system files. Including ones critical to the operating system.

The cp command can be used to copy files

 

man cp

       cp [OPTION]… -t DIRECTORY SOURCE

DESCRIPTION

       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

 

 

The mv command is used to move files or rename them

NAME

       mv – move (rename) files

SYNOPSIS

       mv [OPTION]… [-T] SOURCE DEST

       mv [OPTION]… SOURCEDIRECTORY

       mv [OPTION]… -t DIRECTORY SOURCE

DESCRIPTION

       Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

The rm command removed files

NAME

       rm – remove files or directories

SYNOPSIS

       rm [OPTION]… FILE

DESCRIPTION

       This  manual  page  documents  the  GNU version of rmrm removes each

       specified file.  By default, it does not remove directories.

pwd shows the current working directory

ubuntu@ip-10-111-173-20:~$ pwd

/home/ubuntu

cat shows the content of a file

NAME

       cat – concatenate files and print on the standard output

SYNOPSIS

       cat [OPTION]… [FILE]…

DESCRIPTION

       Concatenate FILE(s), or standard input, to standard output.

The ls command is like dir in windows

NAME

       ls – list directory contents

SYNOPSIS

       ls [OPTION]… [FILE]…

DESCRIPTION

       List  information  about  the FILEs (the current directory by default).

       Sort entries alphabetically if none of -cftuvSUX nor –sort  is  speci‐

       fied.

ls -l shows the permissions on a file permissions in linux work like this

there are three groupings of letters owner group others each grouping has some or all of the letters rwx which stands for Read Write and eXecute

You change the permissions with the chmod command you change the owner with the chown command

You can create a file with the touch command.

 

NAME

       touch – change file timestamps

SYNOPSIS

       touch [OPTION]… FILE

DESCRIPTION

       Update  the  access  and modification times of each FILE to the current

       time.

       A FILE argument that does not exist is created empty, unless -c  or  -h

       is supplied.