Command Lines for Terminal in Ubuntu
• Directory = file
o a file which consists solely of a set of other files
• While typing a file, press Tab for it to finish automatically
• ls (or l) = gives the list of all files in the directory you are currently in
• ls -l = the same as above but more detailed
• mkdir = makes a new directory
• cd = change directory (go into that directory)
• mv ??1 ??2 = changes the name of ??1 into ??2
• mv ??1 ~/??2/ = moves ??1 into the ??2 directory (/ = directory)
• Ctrl-k-x = saves the java file (or probably any file)
• more ??.java = prints the code out to the screen
• javac ??.java = compiles java program
• java ?? = Runs java program (leave out .java)
• joe Makefile = creates a new Makefile
• make = compiles the updated version of the file you file you changed (either it
will say it is up to date or it will say eg. “javac ??.java” which means it was
compiled/updated
• In a Makefile, you can create a rule to delete all .class files, which are the
compiled files. This way, you can only leave the source files
o clean:
rm. *.class [remove all class files]
• more Makefile = see what’s in the Makefile
• less ?? = does the same task as more but better
• Source directory (.java) vs bin directory (.class)
• joe ?? = opens up file
• In the Makefile if I say:
o run:
????
, o It means that I can now say make run and it runs the line of ??? code
automatically like auto replacement
• rm ?? = remove/delete file
• rm -r dirname/ = remove a directory
• rmdir ?? = remove/delete directory
• rm -r .git/ = remove git repository with everything inside
• git add name.java = adding .java to a git
• git commit -m 'message' = committing 2 files to be part of repository
• ??~ = backup file
• cd = go to home directory
• joe ??1/??2 = open a file that is in another directory within the directory you
are in
• cp = used to create a copy ie. cp HelloWorld.java HelloWorld_Copy.java
• cd .. = goes back to the previous/bigger/parent directory
• Ctrl-Shift-- = undo
• Ctrl-Shift-^ = redo
• Ctrl-Shift-+ = zoom in
• Ctrl-- = zoom out
• cd ../?? = move out of current directory into another director in its parent’s
directory
• q = while using the “more” command on a large file and you want to exit early
• java ?? > ??.txt = output redirection into new txt file
• java ?? >> ??.txt = output redirection into existing txt file
• rm *.txt (or any file extension) = removes all existing files with that extension
in that directory
• python ??.py = run python file from joe
• tar -zcvf myfolder.tar.gz myfolder = gzip.tar a whole Assignment
• tar -cf HelloWorld.tar HelloWorld = gathering files into single archive file
• gzip HelloWorld.tar = compresses a file
• tar -cf - Assignment 1 | gzip > assignment.tar = does above 2 in one go
• gzip -cd test.tgz = unzips and untars test.tgz
• tar -xf ??.tar.gz = unzip a tar.gz file
• Directory = file
o a file which consists solely of a set of other files
• While typing a file, press Tab for it to finish automatically
• ls (or l) = gives the list of all files in the directory you are currently in
• ls -l = the same as above but more detailed
• mkdir = makes a new directory
• cd = change directory (go into that directory)
• mv ??1 ??2 = changes the name of ??1 into ??2
• mv ??1 ~/??2/ = moves ??1 into the ??2 directory (/ = directory)
• Ctrl-k-x = saves the java file (or probably any file)
• more ??.java = prints the code out to the screen
• javac ??.java = compiles java program
• java ?? = Runs java program (leave out .java)
• joe Makefile = creates a new Makefile
• make = compiles the updated version of the file you file you changed (either it
will say it is up to date or it will say eg. “javac ??.java” which means it was
compiled/updated
• In a Makefile, you can create a rule to delete all .class files, which are the
compiled files. This way, you can only leave the source files
o clean:
rm. *.class [remove all class files]
• more Makefile = see what’s in the Makefile
• less ?? = does the same task as more but better
• Source directory (.java) vs bin directory (.class)
• joe ?? = opens up file
• In the Makefile if I say:
o run:
????
, o It means that I can now say make run and it runs the line of ??? code
automatically like auto replacement
• rm ?? = remove/delete file
• rm -r dirname/ = remove a directory
• rmdir ?? = remove/delete directory
• rm -r .git/ = remove git repository with everything inside
• git add name.java = adding .java to a git
• git commit -m 'message' = committing 2 files to be part of repository
• ??~ = backup file
• cd = go to home directory
• joe ??1/??2 = open a file that is in another directory within the directory you
are in
• cp = used to create a copy ie. cp HelloWorld.java HelloWorld_Copy.java
• cd .. = goes back to the previous/bigger/parent directory
• Ctrl-Shift-- = undo
• Ctrl-Shift-^ = redo
• Ctrl-Shift-+ = zoom in
• Ctrl-- = zoom out
• cd ../?? = move out of current directory into another director in its parent’s
directory
• q = while using the “more” command on a large file and you want to exit early
• java ?? > ??.txt = output redirection into new txt file
• java ?? >> ??.txt = output redirection into existing txt file
• rm *.txt (or any file extension) = removes all existing files with that extension
in that directory
• python ??.py = run python file from joe
• tar -zcvf myfolder.tar.gz myfolder = gzip.tar a whole Assignment
• tar -cf HelloWorld.tar HelloWorld = gathering files into single archive file
• gzip HelloWorld.tar = compresses a file
• tar -cf - Assignment 1 | gzip > assignment.tar = does above 2 in one go
• gzip -cd test.tgz = unzips and untars test.tgz
• tar -xf ??.tar.gz = unzip a tar.gz file