Useful Commands For The Linux Command Line
Useful commands for the Linux command lineThis short guide shows some important commands for your daily work on the Linux command line. archOutputs the processor architecture.$ arch i686 catOutputs the contents of a file.$ cat lorem.txt Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. cdChange the working directory.$ cd /bin chgrpChange group ownership of files.$ chgrp games moo.txt chmodChange access permissions of files.$ chmod +x helloworld chownChange file owner and group.# chown root lorem.txt cksumPrint CRC checksum and byte counts of each file.$ cksum lorem.txt moo.txt 3570240675 453 lorem.txt cpCopies a file.$ cp lorem.txt copy_of_lorem.txt dateOutputs the current date and time.$ date Sat Mar 3 12:07:09 GMT 2007 dfReports the amount of disk space used and available on filesystems.$ df Filesystem 1K-blocks Used Available Use% Mounted on<br> dirList directory contents.$ dir copy_of_lorem.txt lorem.txt moo.txt www duEstimate file space usage.$ du -h /bin 7.8M /bin echoDisplay a line of text.$ echo foobar foobar exitCause the shell to exit.$ exit fgrepPrint lines matching a pattern in a file.$ fgrep "irure dolor" lorem.txt commodo consequat. Duis aute irure dolor in reprehenderit in voluptate findSearch for files in a directory hierarchy.$ find hello* hello_world freeDisplay amount of free and used memory in the system.$ free total used free shared buffers cached grepPrint lines matching a pattern.$ grep -i apple fruitlist.txt apple groupsOutputs the user groups of which your account belongs to.$ groups games users headOutput the first part of files.$ head -2 lorem.txt Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod hostnameOutputs the machines hostname on the network.$ hostname anapnea.net idOutputs user id, group id, and groups of your account.$ id uid=1478(smallfoot) gid=100(users) groups=35(games),100(users) killEnd a process.$ kill -9 18298 -bash: kill: (18298) - Operation not permitted killallKill processes by name.$ killall irssi irssi(18298): Operation not permitted lastShow listing of last logged in users.$ last -n 3 alice pts/6 192.0.34.166 Fri May 18 16:17 still logged in lddPrint shared library dependencies.$ ldd /bin/bash libncurses.so.5 => /lib/libncurses.so.5 (0x40023000) lnMake links between files.$ ln -s data.txt symlink.txt lognamePrint user's login name.$ logname smallfoot lsList directory contents.$ ls copy_of_lorem.txt lorem.txt moo.txt www manOpens the manual page for a software or function.$ man bash md5sumOutputs the MD5 hash sum of a file.$ md5sum lorem.txt 56da9e37259af34345895883e6fd1a27 lorem.txt mkdirMakes a directory.$ mkdir foobar mvMoves a file.$ mv lorem.txt ipsum.txt nlNumber lines of files.$ nl lorem.txt 1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod nmList symbols from object files.$ nm hello_world 080494a0 D _DYNAMIC odDump files in octal and other formats.$ od -t x /bin/sh 2376640 00098020 000054d4 00000000 00000000 pidofFind the process ID of a running program.$ pidof fetchmail 22392 pingPings a host.$ ping -c 2 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. psOutputs running processes.$ ps PID TTY TIME CMD pstreeDisplay a tree of processes.$ pstree init-+-2*[BitchX] pwdOutputs the name of current working directory.$ pwd /home/smallfoot rmRemoves a file or directory.$ rm lorem.txt rmdirRemoves a directory.$ rmdir foobar sedStream editor for filtering and transforming text.$ echo "My cat's name is Bob" | sed -e 's/Bob/Mittens/g' My cat's name is Mittens sha1sumOutputs the SHA1 hash sum of a file.$ sha1sum lorem.txt c942ddebd142ec8bacac9213d48096e74bab4957 lorem.txt shutdownBring the system down in a secure way. All logged-in users are notified that the system is going down.$ shutdown now sizeList section sizes and total size.$ size /bin/bash text data bss dec hex filename statOutputs file status.$ stat lorem.txt File: `lorem.txt' stringsPrint the strings of printable characters in files.$ strings hello_world /lib/ld-linux.so.2 tailOutput the last part of files.$ tail -2 lorem.txt occaecat cupidatat non proident, sunt in culpa qui officia deserunt talkTalk to another user.$ talk bob Lookout for the dopefish! touchChange a file's access and modification timestamps. If file does not exist, create it.$ touch lorem.txt ttyOutputs the name of the current terminal.$ tty /dev/pts/16 unameOutputs operating system, hostname, kernel version, date and timp, and processor.$ uname -a Linux anapnea.net 2.6.9 #1 SMP Wed Jul 19 16:24:18 MSD 2006 i686 Intel(R) Xeon(TM) CPU 2.80GHz GenuineIntel GNU/Linux uptimeOutputs the system uptime.$ uptime 14:50:26 up 7 days, 17:52, 18 users, load average: 0.08, 0.02, 0.01 usersPrint the user names of users currently logged in to the current host.$ users alice bob charlie eve vdirList directory contents.$ vdir total 8 wShow who is logged on and what they are doing.$ w 12:14:30 up 5 days, 15:16, 19 users, load average: 0.00, 0.00, 0.00 wallSend a message to everybody's terminal.$ wall next week we change the server for a new one wcCounts lines in a file.$ wc -l lorem.txt 7 lorem.txt whatisSearch the whatis database for complete words.$ whatis bash bash (1) - GNU Bourne-Again SHell whoOutputs who is currently logged into the system.$ who charlie pts/0 Mar 2 21:37 (xtreme-11-65.acme.com) whereisLocate the binary, source, and manual page files for a command.$ whereis bash bash: /bin/bash /etc/bash /usr/share/man/man1/bash.1.gz whoamiOutputs your username / the name of your account.$ whoami smallfoot
|






Recent comments
10 hours 28 min ago
11 hours 25 min ago
11 hours 37 min ago
17 hours 42 min ago
20 hours 11 min ago
21 hours 22 min ago
1 day 36 min ago
1 day 1 hour ago
1 day 2 hours ago
1 day 5 hours ago