Linux Shell Cheat Sheet

ADVERTISEMENT

Linux Shell Cheat Sheet
(courtesy of David Letscher)
Directories and files
ls
List contents of current directory.
pwd
Give full path of current directory.
cd {path}
Change directories to path,
e.g. cd sub changes directory into the subdirectory named sub.
cd ..
Change current directory to the parent directory.
cd
Change current directory to your home directory.
mkdir {dirname}
Create a directory named dirname.
rmdir {dirname}
Remove a directory name dirname (if empty).
mv {oldname} {newname}
Move/rename a file, e.g. mv foo foo.old renames the file foo to foo.old.
rm {filename}
Remove/delete a file.
cp {fromname} {toname}
Copy a file, e.g. cp foo foo.old copies foo to foo.old
cp -R {dirname} {toname}
Copy a directory, e.g. cp originalFiles myProject
Getting help
man {command}
Get help on the command, e.g. man ls for help on the ls command.
whatis {command}
Give short description of command.
apropos {keyword}
Search for all Linux commands that match keyword.
Viewing and editing files
cat {filename}
View a file.
more {filename}
View a file one screen at a time.
emacs {filename}
Edit a file.
emacs {filename} &
Edit a file in a separate window (if graphical login)
C++
g++ -o {executableName} {sourcecode.cpp}
compile sourcecode.cpp into executable
g++ -c {sourcecode.cpp}
compile sourcecode.cpp into object code sourcecode.o
make
(re)build an executable based upon makefile.
1

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go