Introduction to Python
Mac/Linux and Windows Command Line Reference
. (one dot) in a path = current
dir; .. (two dots) = parent dir; * (asterisk)
in a filename = "any chars"
relative path: relative to current directory, starting with file or dir name; absolute path: starting with / or C:\
command |
Mac / Linux |
Windows |
show current or present working directory |
pwd
|
not needed – pwd is displayed in every prompt |
change directory
change to a relative path dir change to an absolute path dir change to parent directory change to dir in parent dir |
cd
cd mydir cd /Users/david/mydir cd .. cd ../otherdir |
cd
cd mydir cd C:\Users\david cd .. cd ..\otherdir |
|
|
|
list a directory
list present directory list a relative path dir list an absolute path dir list parent directory list a dir in parent dir list only .txt files |
ls
ls ls mydir ls /Users/david/mydir ls .. ls ../otherdir ls *.txt |
dir
dir dir mydir dir C:\Users\david dir .. dir ..\otherdir dir *.txt |
|
|
|
make a directory
make a dir in current dir make a dir in parent dir |
mkdir
mkdir newdir mkdir ../othernewdir |
mkdir
mkdir newdir mkdir ..\othernewdir |
display contents of a file
|
cat
cat thisfile.txt |
type
type thisfile.txt |
copy a file
|
cp
cp this.txt that.txt |
copy
copy this.txt that.txt |
move a file
rename a file move a file to a relative path dir move a file to parent dir move a file from dir to present dir |
mv
mv thisfile.txt that.txt mv thisfile.txt mydir/ mv thisfile.txt .. mv mydir/thisfile.txt . |
move
move this.txt that.txt move this.txt mydir\ move this.txt .. move mydir\this.txt . |
remove a file
|
rm
rm thisfile.txt |
del
del thisfile.txt |
remove a directory
|
rmdir
rmdir mydir/ |
rmdir
rmdir mydir/ |
change permissions on a file
|
chmod
chmod 755 myprog.py |
not used in Windows |