Basic Linux Commands

The most important to be known for using LINUX is the commands. Below is some of the Basic Linux Commands.

* - Be Careful while using this Command

File Commands

ls — for directory listing

ls -al — Formatted Listing with hidden files

cd <dir> — Change directory to <dir>

cd — Change to home directory

pwd — shows the current working directory

mkdir <dir> — create a directory <dir>

rm <file> — Delete <file>

rm -r <dir> — delete directory <dir>

rm -f <file> — force remove <file>

rm -rf <dir> — force remove directory <dir> *

cp <file1> <file2> — copy <file1> to <file2>

cp -r <dir1> <dir2> — Copy <dir1> to <dir2>, creates dir2 if it doesn’t exist.

mv <file1> <file2> — Rename or Move <file1> <file2>, if file2 is an existing directory, moves <file1> into directory <file2>

ln -s <file1> <link> — Create symbolic <link> to <file1>

touch <file> — Create an empty file.

cat > <file> — Pleaces standard input into file

more <file> — Output the contents of file

read <file> — Output the first 10 lines of file

tail <file> — Output the last 10 lines of file

tail -f <file> — Output the contents of file as it grows, starting with the last 10 lines

Process Management
ps — Display your currently active processestop — Display all running processeskill <pid> — Kill process id pidkillall <proc> — Kill all processes named <proc> *bg — Lists stopped or background jobs; resume a stopped job in the background

fg — Brings the most recent job to foreground

fg n — Brings job n to the foreground

File Permissions
chmod octal file — Change the permissions of file to octal, which can be found separately for user, group, and world by adding:

  • read (r)
  • write (w)
  • execute (x)

Examples:

chmod 777 <file> — read, write, execute for all of a <file>

chmod 755 <file> — rwx for owner, rx for group and world of a <file>

chmod -R 755 <dir> — rwx for owner, rx for group and world of a <dir>

For more options, see man chmod.

SSH

ssh user@host — Connect to host as user

ssh -p port user@host — Connect to host on port

port as user

ssh-copy-id user@host — Add your key to host for user to enable a keyed or passwordless login

Example:

ssh guest@172.168.60.25 — if the Hostname of the remote machine is not known/Entry not in the Hosts List(/etc/hosts).

ssh guest@<remote_hostname>– If the Hostname of the remote machine is known.

Searching

grep pattern files — Search for pattern in files

grep -r pattern dir — Search recursively for pattern in dir

command | grep pattern — Search for pattern in the output of command

locate file — Find all instances of file.

System Info

date — Show the current date and time

cal — Show this month’s calendar

uptime — Show current uptime

w — Display who is online

whoami — Who you are logged in as

finger user — Display information about user

uname -a — Show kernel information

cat /proc/cpuinfo — CPU information

cat /proc/meminfo — Memory information

man <command> — Show the manual for command

df — Show disk usage

du — Show directory space usage

free — Show memory and swap usage

whereis <app_name> — Show possible locations of app (ex: whereis ls)

which <app_name> — Show which app will be run by default

Compression

tar -cvf <file.tar> <files> – create a tar named <file.tar> containing <files>

tar -xvf <file.tar> — Extract the files from <file.tar>

tar -cvzf <file.tar.gz> <files> — Create a tar with Gzip compression

tar -xvzf <file.tar.gz> — Extract a tar using Gzip

tar -cvjf <file.tar.bz2> — Create a tar with Bzip2 compression

tar -xvjf <file.tar.bz2> — Extract a tar using Bzip2

gzip <file> — Compresses file and renames it to <file.gz>

gzip -d <file.gz> — Decompresses <file.gz> back to <file>

Network

ping <host/IP> — Ping host/IP and output results

whois domain — Get whois information for domain

dig domain — Get DNS information for domain

dig -x host — Reverse lookup host

wget <file> — Download file

wget -c <file> — Continue a stopped download

Installation

Install from source:

./configure

make

make install

dpkg -i pkg.deb – install a package (Debian)

rpm -Uvh pkg.rpm – install a package (RPM)

For Detailed: http://blog.linuxgalore.com/2007/11/27/how-to-install-a-software-in-linux-from-source/

Shortcuts

Ctrl+C — Halts the current command

Ctrl+Z — Stops the current command, resume with fg in the foreground or bg in the background

Ctrl+D — Log out of current session, similar to exit

Ctrl+W — Erases one word in the current line

Ctrl+U — Erases the whole line

Ctrl+R — Type to bring up a recent command

!! — Repeats the last command

exit — Log out of current session

Keep checking for more updates on this…………… and leave your comments.

Popularity: 72% [?]

5 Responses to “Basic Linux Commands”

  1. These command is very useful for those students knowing linux with text mode.

  2. Hello webmaster Wow what a fantastic article about Reverse Ip Lookup! Your keen insight into Reverse Ip Lookup is informative and creative. I look forward to reading other articles you have. Thanks.

  3. We like your blog!…

    […]Mabuhay, my colleagues and I heard of your blog over at McBrides, so we thought we would take a look. We’ve read several of your posts and we all agree that you have a fine writing style[…]

  4. Hi! I am thoroughly impressed with your knowledge of Reverse Ip Lookup. Your insights into this article about Reverse Ip Lookup was well worth the the time to read it. I thank you for posting such awsome information. Signed James Kryten on this Day Friday.

  5. Hi My name is Megan, and I have been searching the web in regards to Ip Lookup for what seems like ages now. Its really nice to know that someone out there is really writing great articles about Ip Lookup. I\’ll be back to read other articles you have. Signed this day (Friday).

Leave a Reply

Close
E-mail It
Blogarama - The Blog Directory Directory of Computers/Tech Blogs Add to Technorati Favorites Find Blogs in the Blog
Directory Software blogs Top Blogs British Blog Directory. FindingBlog - Blog Directory blog search directory blog sweet blogoriffic.com Top100 Bloggers - Top Blog Directory - Blog Top list Blogs Blog Directory 5starblogs Age less highclassblogs.com kmax.ws Blog Directory & Search engine Blogs Directory All-Blogs.net directory Webfeed (RSS/ATOM/RDF) registered at http://www.feeds4all.com Business Blogs & Directory LS Blogs

Rate Me on BlogHop.com!
the best pretty good okay pretty bad the worst help?

-->