You are on page 1of 3

Linux commands

echo $SHELL
clear
cd / - root directory
cd /usr
cd local/bin
pwd - show parent working directory
cd .. previous directory - one back
cd .. /share -in the current dir, go to a folder named share
jobs -l == list current jobs
ps au - cpu util
ps al
ps ax / ps a/ ps x
ps x --forest [pareny child process displayed]
top === displays a continuously updated process listing
fg == To get the process "un-stopped" and running again, we can bring it to the foreground with the
bash built-in fg
bg == continue it in the background with the bash built-in bg
lsmod == list of currently loaded modules
uname -a = System info about OS

$ nice -n 10 oggenc /tmp/song.wav ===set the priority of a process - change the priority of a
process when you start it
renice 10 641====change the niceness setting of a running process
$ ls -l /bin/bash
-rwxr-xr-x 1 root wheel
430540 Dec 23 18:27 /bin/bash
The first triplet represents permissions for the owner of the file, the second represents permissions
for the file's group, and the third represents permissions for all other users
vi == i - insert, esc :q = quit, esc :wq save and quit
q = interrupt a process
whoami -tells the current user
groups == current group
whatis ls

info = page navigation info


man -k whatis = exact definition
ls -s | sort -n == sort files by name list by file size
ls -t == sort file by last modified date
ls -tr == sort file by created date
ls - lt == Long listing format sorted by date/time
ls -s == sort files by size
ls -ls == long listing format with file size
ls -S == list sorted by file/directories size
ls -a == list with hidden files/directories
ls -la == long listing format with hidden files/directories
$ ls -ld my* list file and directory
echo -e "foo\nfoo" == prints foo on new line
echo -n "foo\nfoo" == ignores newline
head foo.txt == prints first 10 lines
head -2 foo.txt == prints first 2 lines
tail foo.txt == prints last 10 lines
tail -2 foo.txt == prints last 2 lines
tac = like cat, but prints all lines in reverse order
expand== converts input tabs to spaces. Use the -t option to specify the tabstop.
unexpan d== converts input spaces to tabs. Use the -t option to specify the tabstop.
cut == to extract character-delimited fields from each line of an input file or stream.
nl == adds a line number to every line of input. Useful for printouts.
pr == break files into multiple pages of output; typically used for printing.
tr == character translation tool; it's used to map certain characters in the input stream to certain
other characters in the output stream.
od == transform the input stream into a octal or hex "dump" format.
split == split a larger file into many smaller-sized, more manageable chunks.
fmt == reformat paragraphs so that wrapping is done at the margin. These days it's less useful since
this ability is built into most text editors, but it's still a good one to know.
paste == takes two or more files as input, concatenates each sequential line from the input files, and
outputs the resulting lines. It can be useful to create tables or columns of text.
join==s similar to paste, but it uses a field (by default the first) in each input line to match up what
should be combined on a single line.
tee == prints its input both to a file and to the screen. This is useful when you want to create a log of
something, but you also want to see it on the screen.

$ sort <<END
apple
cranberry
banana
END
echo Hi > myfile == overwrites file
$ echo there. >> myfile == appends to file

Linix Boot > BIOS reads MBR > MBR Master boot record (info about the location of the Kernel)
> loads kernel into memory > after kernel loads, it calls program called init > init boots rest of the
distribution > init starts program called getty > getty displays the login screen
Maintenance of MBR Bootloader 2 types : GRUB (Grand Unified Bootloader) and LILO(LInux
Loader)
f the error occurred while the kernel was loading or probing hardware devices, you can retrieve a
copy of the kernel's log using thedmesg command or /var/log/messages
grep named /var/log/messages | tail -3
cd /var/log
tail messages
tail -f /var/log/messages

~/Downloads is the same as /Users/<yourname>/Downloads.


"/" to denote the root;
"~" to refer to your home directory;
".." (double-dot) to refer to the parent directory;
"." (single-dot) to refer to the current directory;
"-" (dash) to refer to the previous directory.
cd ~

// Change directory to the home directory of the current user

$ cd
// same as above, default for "cd" is home directory
$ cd ~/Documents // Change directory to the sub-directory "Documents" of the home directory
of the current user
$ cd ..
// Change directory to the parent directory of the current working directory
$ cd // Change directory to the previous working directory (OLDPWD)

cd ~/myproject/java // Set the working directory


$ javac Hello.java
// Filename only, in current directory

You might also like