Difference between revisions of "Linux commands"
(→Navigation) |
|||
Line 41: | Line 41: | ||
* <code>mv ''file1'' ''file2''</code> - move and/or rename <code>''file1''</code> to <code>''file2''</code> | * <code>mv ''file1'' ''file2''</code> - move and/or rename <code>''file1''</code> to <code>''file2''</code> | ||
* <code>cp ''file1'' ''file2''</code> - copy <code>''file1''</code> to <code>''file2''</code> | * <code>cp ''file1'' ''file2''</code> - copy <code>''file1''</code> to <code>''file2''</code> | ||
+ | ** Both <code>cp</code> and <code>mv</code> will overwrite the destination file if it already exists |
Revision as of 23:54, 20 January 2018
This page details some common and useful Linux commands
Miscellany
-
exit
- end the terminal session -
clear
- clear the terminal screen -
history
- view your command history
Command information
-
man command
- read the manual page forcommand
Paths
In every file system files are organized into various folders or directories. A path describes the location of a file or directory and can be relative or absolute. For instance, suppose a file system has the following folders:
-
/
-
/dirA
-
/dirB
-
/dirB/files
If we wish to examine a file listing of /dirB/files
and our current directory is /dirB
then we can issue the command ls files
(relative path) or /dirB/files
(absolute path)
Additionally, there are special symbols with respect to paths that can be used:
-
.
- current directory -
..
- parent directory (one level up) -
~
- home directory
-
pwd
- print the current directory you are in -
ls
- list files in the current directory -
ls -l
- list files with complete details in the current directory -
ls -a
- list all files in the current directory (including hidden files starting with.
) -
ls directory
- list files indirectory
-
cd directory
- makedirectory
the current directory -
cd ..
- make the parent directory the current directory -
cd
- make your home directory the current directory -
mkdir directory
- create a subdirectory -
rmdir directory
- remove a directory (only if empty) -
rm filename
- remove a file -
rm -rf directory
- delete a directory and all contents within -
rm *
- remove all files in the current directory -
mv file1 file2
- move and/or renamefile1
tofile2
-
cp file1 file2
- copyfile1
tofile2
- Both
cp
andmv
will overwrite the destination file if it already exists
- Both