0% found this document useful (0 votes)
41 views

Ls - A - Ls .Newsrc

The document discusses several Linux commands for file and directory management: ls lists directory contents, cp copies files, mv moves or renames files, rm removes files, pwd prints the working directory, cd changes directories, mkdir creates directories, rmdir removes empty directories, chmod modifies file permissions, and man accesses command manuals. Each command has basic usage examples provided.

Uploaded by

Tej Sha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Ls - A - Ls .Newsrc

The document discusses several Linux commands for file and directory management: ls lists directory contents, cp copies files, mv moves or renames files, rm removes files, pwd prints the working directory, cd changes directories, mkdir creates directories, rmdir removes empty directories, chmod modifies file permissions, and man accesses command manuals. Each command has basic usage examples provided.

Uploaded by

Tej Sha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ls Lists the contents of your working directory.

ls -a Lists all of your files, including the "dot" files. There are a number of files that
start with a . that won't normally show up with when you type ls. An example of such
a file is your .newsrc file.

ls -s Gives you a listing of your files along with their size in kilobytes.

ls -l Gives you a "long listing," which means that your files will be shown in one
vertical column and the file size and file access modes for all files will be shown.

All of these switches can be combined, so one might type ls -as to list all of one's
files and find their size.

cp Copies a file to a specified location. Can be used to copy a directory with files in it
using cp –r .

Usage: cp [ -r ] [source file(s) or directory(ies)] [destination file(s) or directory(ies)]

Examples:
cp ~/myfile ~/mydir/
cp file1.txt newfile.txt
cp –r ~/myproject/ ~/myprojectbackup/

mv Moves (or renames) a file to a specified location. Similar to cp except that it deletes
the source file (or directory, no option needed).

Usage: mv [source file(s) or directory(ies)] [destination file or directory(ies)]

Examples:
mv ~/myoldfilename ~/mynewfilename
mv file* ~/mydirectoryoffiles/
mv ~/mydir/ ~/myotherdir/

rm Deletes file(s) or directory trees. There is no undoing! Can be used to delete all files
and subdirectories with rm –rf .
Usage: rm [-rf] [file or directory]

Examples:
rm mytxtfile.txt
rm –rf ~/mydir/ (removes the directory and everything in it)
rm –rf ~/ (don't do this!)

pwd Prints the working directory. This could be called your current path or view.

cd Changes your working directory or view or where you're “in” to another specified
location.

Usage: cd [destination path]

Examples:
cd ~/ (home directory)
cd somedir/someotherdir/
cd / (root directory)
cd .. (parent directory)

mkdir Creates a new directory. You can specify a location if you like.

Usage: mkdir [directory path and name]

Examples:
mkdir newdir
mkdir ~/newdir
mkdir olddir/newdir

rmdir Removes (deletes) a directory. You can only use this on empty directories.

Usage: rmdir [directory path and name]

Examples:
rmdir ~/olddir
rmdir olddir/empty/

chmod Modifies the permissions of files or directories. Permissions are rules about how and
which users can access the files or directories. The three switches covered here
are: r -read access, w -write access, x –execute access.

Usage: chmod [ + or - ]rwx [file(s) or directory]

Examples:
chmod +r myfile (adds read access to a myfile)
chmod –w myfile (removes write access to myfile)
chmod +x myfile (adds execute access to myfile)

man The man Linux tool is shorthand for "manual." Most Linux programs and utilities have
brief documentation installed on the system. In order to access these online manuals,

Usage: man [program name]

You might also like