Low Orbit Flux Logo 2

Linux / Unix Commands


pipes | , w/ cat grep more less cut redirecting > » &>

~ home

These are the most basic Unix/Linux commands so you can start to feel at home in a Unix environment. Many, many commands exist and will vary based on the exact system you are using.

After covering this you should be able to work in a Unix / Linux environment. This does not cover every tool that exists. This guide will not cover everything you need to be a good admin.

NOTE - Anything after the character ‘#’ is a comment and doesn’t actually get executed.

NOTE - use ‘tab’ to auto complete a command or path

man ls
help ls
type ls

history    # show your command history
[up]       # show last command


ls -a        # show hidden files
ls -l
ls -lh
ls -ltr
ls -l *.txt
ls -l *secret*

cd mydir
cd /home/user1/mydir
cd ..
cd ../../dir1
cd My\ Music
cd ~       # home directory
cd ~user2  # home directory
cd -       # previous directory

touch file1.txt     # create file or change last written time if it exists
file  file1.txt     # check file type

rm file1.txt

mkdir testdir1

rmdir testdir1          # only works if empty

rm -rf testdir1         # recursively and force delete

mkdir newdir/subdir     # won't work if "newdir" doesn't exist yet

mkdir -p newdir/subdir  # -p makes it work recursively

clear bc jobs / bg cal chgrp md5sum dd if=/home/tecmint/kali-linux-1.0.4-i386.iso of=/dev/sdc1 bs=512M; sync eject /dev/cdrom env hwinfo ifconfig / other network commands route arp etc. netstat / iostat / lsof / fuser ionice lscpu lspci lsblk lsusb lshw nc nice pidof init pstree ssh scp sleep stat touch tac talk time tr watch which whereis xargs yes

adduser/useradd …. cron anacron at

cp file1.txt file2.txt     # copy to a new file
cp file1.txt dir1          # copy into a directory
cp -R dir1 dir2            # copy dir ( needs -R )

NOTE - to rename a file, just use the ‘mv’ command to move the file to a different name.

mv file1.txt file2.txt          # move file ( basically renames it )
mv file1.txt dir1/sub3          # move into a directory ( keep file name )
mv file1.txt dir1/sub3/file2.txt     # move move into a directory with new name

ln -s

locate newFile.txt
locate -i newFile.txt        # case insensitive
locate -i *something*blah*   # anything that matches these two words

find .....
find . -name *ones*
find . -type f -name *ones*
find . -iname *wild*

nano # a popular text editor these days pico # also popular jed # another editor vi # traditional Unix text editor, on almost every system that exists, tricky if you aren’t familiar with it emacs # similar to vi but with completely different commands, some people like this better

echo "hello world"

cat mytextfile.txt        # output contents of this file
cat file1.txt file2.txt   # concatenate these two files together and output the content
cat > filename

head myfile.txt           # print first 10 lines of file
head -n 1000 myfile.txt   # print first 1000 lines of file

tail myfile.txt           # print last 10 lines of file
tail -n 1000 myfile.txt   # print last 1000 lines of file

tail -n 1000 -f myfile.txt   # print last 1000 lines of file and follow
                             # good for log files, shows updates to file as they come in

more   # page through a file ( press space to see more )
less   # same as more but better ( more features like going back )

[Page Up]  Scroll back one page
b          Scroll back one page
[Page Down]   Scroll forward one page
[space]  Scroll forward one page
G  Go to the end of the text file
1G  Go to the beginning of the text file
/characters  Search forward in the text file for an occurrence of the specified characters
n  Repeat the previous search
h  Display a complete list less commands and options
q  Quit

grep someinfo test.txt      # search for a string in a file
grep -i someinfo test.txt   # case insensitive
grep -r someinfo *          # recursivly search all files
grep -r someinfo            # same but location is optional

free -m
free -h

su - user2      # become user2 ( need user2's password unless you are root )
su -            # become root user ( need root passwd )

sudo somecommand        # run a command as root ( if you have permissions )
sudo su -          # use sudo to become root ( use your own password )

ps -ef
ps -aux

NOTE about output ( user PID PPID )


p ....

us: value is the CPU time the CPU spends executing processes for users, in “user space” sy: value is the CPU time spent on running system “kernel space” processes ni: value is the CPU time spent on executing processes with a manually set nice value id: is the amount of CPU idle time wa: value is the time the CPU spends waiting for I/O to complete hi: The CPU time spent servicing hardware interrupts si: The CPU time spent servicing software interrupts st: The CPU time lost due to running virtual machines (“steal time”)

PID: Process ID USER: Name of the owner of the process PR: Process priority NI: The nice value of the process VIRT: Virtual memory used by the process RES: Resident memory used by the process SHR: Shared memory used by the process S: Status of the process. See the list below of the values this field can take %CPU: the share of CPU time used by the process since last update %MEM: share of physical memory used TIME+: total CPU time used by the task in hundredths of a second COMMAND: command name or command line (name + options)

D: Uninterruptible sleep R: Running S: Sleeping T: Traced (stopped) Z: Zombie

nice renice


commands to sort output

kill 1692 # kill a process with pid 1692

df -k
df -h
df -h /var

du data   
du data | sort -nr

ls | sort


tar xvf myPackage.tar        # extract, verbose, file
tar xvfz myPackage.tar.gz    # extract, verbose, file, ungzip 
tar xvfj myPackage.tar.gz    # extract, verbose, file, unbzip
tar -cvf myarchive.tar myfolder/      # create a tar file
tar -cvfz myarchive.tar.gz myfolder/  # create a tar.gz file
tar -cvfj myarchive.tar.gz myfolder/  # create a tar.bz2 file
gzip somefile.txt
gzip -k somefile.txt    # keep original


uname -a
uname -s  # kernel name
uname -r  # kernel release 
uname -v  # kernel version


uptime    # how long the system has been up and the load factor

w                    # who is logged in
who                  # who is logged in 
last                 # show history of logins
whoami               # show your username
getent passwd user1  # get account info
id                   # show your username, group, etc.
finger  user1        # user info if installed

/etc/passwd /etc/shadow

shutdown       # shutdown in 1 min
shutdown now   # shutdown now
shutdown +10 Warning, the system will be shutting down in 10 minutes
shutdown 23:00 Warning, the system will be shutting down at 23:00
shutdown -c    # cancel a pending shutdown

reboot .....


cut sed awk pr lp

permissions …..

0: No permission 1: Execute permission 2: Write permission 3: Write and execute permissions 4: Read permission 5: Read and execute permissions 6: Read and write permissions 7: Read, write and execute permissions

user / group / owner

chmod 765 example.txt    
chmod -R 765 example.txt
chmod 755 file.py
chmod u+rx file.py
chmod og-rwx file.py

chown user1:group1 file.py

passwd user1      # change passwd
passwd            # change root password by default
sudo passwd user2 # change someone else's password
sudo passwd       # change root's password ( when you're not root )
groups user1      # show groups user1 is in 



diff file1 file2 uniq …..

exit [ctrl-d]

Package Management:

dpkg apt-get rpm yum more….


ping ifconfig -a ip a tcp dump

wget curl

/ /etc /home /var /usr …..

/etc/passwd /etc/sudoers …..

alias cls=clear alias ll=”ls -l”

.bashrc .profile

cron at

system calls

ssh sshd telnet /etc/services