Linux Command List
addgroup/groupadd
The addgroup commands lets you add a new group to a system.
Example:
Login as root or super user and then execute following commands.
# groupadd group1
# adduser jone group1
adduser/useradd
The adduser commands lets you add a new user to a system. An example for adduser:
#adduser testuser
adding user `testuser' ...
adding new group `testuser' (1003) ...
adding new user `testuser' (1003) with group `testuser' ...
creating home directory `/home/testuser' ...
copying files from `/etc/skel' ...
enter new unix password:
alias
The alias command is used to create a short alias for a long command or group of commands and to launch the command or group of commands using the alias.
The general syntax for the alias command varies somewhat according to the shell. In the case of the bash shell it is
alias [-p] [name="value"]
For example, an alias named ll could be created for the command ls -al as follows:
alias ll="ls -al"
arch
The arch command is used to print the machine's architecture.
$ arch
x86_64
cal/ncal
The cal and ncal commands display a calendar in the output.
cal command is used to display the calendar.
Syntax :
cal [options] [month] [year]
Without any parameter, it display current month.
Examples
To display current month's calendar
$ cal September 2017
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
To display feb 2015 calendar
$ cal 2 2015
February 2015
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
cat
The cat command allows you to concatenate files, or data provided on standard input, and print it on the standard output. in layman terms, the command prints the information provided to it, whether through stdin or in the form a file.
$ cat myfile.txt
This is line one from myfile.txt
cd
The cd command is used to change user's present working directory.
Syntax :
cd [directory | ~ | ./ | ../ | - ]
Examples
$ cd ..
This will change to the parent-directory from the current working directory/sub-directory.
$ cd ~ or $ ch $HOME
This command will move to the user's home directory which is "/home/username".
$ cd /home/userone/
chgrp
The chgrp command allows you to change the group ownership of a file. The command expects new group name as its first argument and the name of file (whose group is being changed) as second argument.
Syntax :
chgrp [options] newgroup filename/directoryname
EXAMPLE:
chgrp neugroup test.txt
The group of 'test.txt' file is root, Change to newgroup neugroup.
chmod
The chmod command lets you change access permissions for a file. for example, if you have a binary file (say helloworld), and you want to make it executable, you can run the following command:
Syntax :
chmod [options] [MODE] FileName
Examples:
To make a file readable and writable by the group and others.
$ chmod 066 myfile.txt - read/write for user and group
----rw-rw- 1 usr grp 757 Oct 26 11:08 myfile.txt
$ chmod 444 myfile.txt - read for everybody
-r--r--r-- 1 usr grp 757 Oct 26 11:08 myfile.txt
Think about the binary code 6=101, 7=111, etc.
1 means permitted, 0 means no permissted.
To allow everyone to read, write, and execute the file
$ chmod 777 myfile.sh
-rwxrwxrwx 1 usr grp 757 Oct 26 11:08 myfile.sh
chmod +x myapp.sh
-r-xr-xr-x 1 usr grp 757 Oct 26 11:08 myapp.sh
Make myapp.sh executable.
chown
The chown command allows you to change the ownership and group of a file.
For example, to change the owner of a file test.txt to root, as well as set its group as root, execute the following command:
chown root:root test.txt
cksum
The cksum command prints the crc checksum and byte count for the input file.
clear
The clear command is used to clear the terminal screen.
cmp
The cmp command is used to perform byte-by-byte comparison of two files.
$ cmp file1 file2
file1 file2 differ: byte 1, line 1
comm
The comm command is used to compare two sorted files line-by-line.
cp
The cp command is used for copying files and directories.
Syntax :
cp [OPTIONS]... SOURCE DEST
cp [OPTIONS]... SOURCE... DIRECTORY
cp [OPTIONS]... --target-directory=DIRECTORY SOURCE...
Examples:
Copy file1 to file2, execute following command:
$ cp file1 file2
You can use -R option to copy whole directory. e.g.
$ cp -R dir_a dir_b
Without -R option you get following error:
$ cp dir_a dir_b
cp: omitting directory `dir_a' meaning dir_a is not copied.
csplit
The csplit command lets you split a file into sections determined by context lines. for example, to split a file into two where the first part contains 'n-1' lines and the second contains the rest, use the following command:
$ csplit file1 [n]
The two parts are saved as files with names 'xx00' and 'xx01', respectively.
date
The date command can be used to print (or even set) the system date and time.
$ date
Thu Oct 26 15:04:20 EST 2017
dd
The dd command copies a file, converting and formatting according to the operands. for example, the following command creates an image of /dev/sda partition.
dd if=/dev/sda of=/tmp/dev-sda-part.img
df
The df command displays how much free disk space is available for each mount.
$ df /dev/sda1
filesystem 1k-blocks used available use% mounted on
/dev/sda1 74985616 48138832 23014620 68% /
diff
The diff command lets you compare two files line by line.
Syntax :
diff [options..] from-file to-file
Example:
$ diff file1 file2
diff3
The diff3 command, as the name suggests, allows you to compare three files line by line.
diff3 file1 file2 file3
dir
The dir command lists directory contents similar to ls.
$ dir
test1 test2 test.7z test.zip
$ dir -l -rw-r--r-- 1 usr grp 58 Oct 26 14:22 a.c -rwxr-xr-x 1 usr grp 6413 Oct 26 14:22 a.out drwxr-xr-x 3 usr grp 4096 Sep 22 2016 java drwxr-xr-x 2 usr grp 4096 Sep 11 10:23 src
dirname
The dirname command strips last component from a file path. in other words, it removes file name or foldername from the absolute path.
$ dirname /home/userone/folder_one
/home/userone
$ dirname /home/userone/file_one
/home/userone
dmidecode
The dmidecode command prints a system's dmi (aka smbios) table contents in a human-readable format.
# dmidecode
# dmidecode 2.12
smbios 2.6 present.
50 structures occupying 2056 bytes.
table at 0x000fcca0.
handle 0x0000, dmi type 0, 24 bytes
bios information
vendor: american megatrends inc.
version: 080015
release date: 08/22/2011
du
The du command displays disk usage of files present in a directory as well as its sub-directories.
Syntax :
du [options] directories
$ du /home/userone
$ du 196 ./fpdf181/makefont 200 ./fpdf181/doc 64 ./fpdf181/font 212 ./fpdf181/tutorial 956 ./fpdf181 2284 ./perl 9268 . $ du -k #displays in kilobytes default 196 ./fpdf181/makefont 200 ./fpdf181/doc 64 ./fpdf181/font 212 ./fpdf181/tutorial 956 ./fpdf181 2284 ./perl 9268 . $ du -b #displays in bytes 124379 ./fpdf181/makefont 68575 ./fpdf181/doc 42135 ./fpdf181/font 159006 ./fpdf181/tutorial 663848 ./fpdf181 4113 ./dload 2265471 ./perl 8761396 .
echo
The echo command displays whatever input text is given to it.
$ echo hello hi
hello hi
ed
ed is a line-oriented text editor.
$ ed
eject
The eject command lets you eject removable media (typically, a cd rom or floppy disk)
$ eject
env
The env command not only displays the current environment, but also lets you edit it.
$ env
HOSTNAME=dragon TERM=xterm SHELL=/bin/bash HISTSIZE=1000 TEMP_DIR=/etc/temp SSH_TTY=/dev/pms/1 USER=userone etc... To set vi for EDITOR, execute
$env EDITOR=vi
Then you can see it with env command.
exit
The exit command causes the shell to exit.
$ exit
expand
The expand command converts tabs present in the input file(s) into spaces, and writes the file contents to standard output.
$ expand file1
expr
The expr command evaluates expressions.
$ expr 5 + 2
Output: 7
factor
The factor command prints the prime factors of the input number.
$ factor 135
135: 3 3 3 5
fgrep
The fgrep command is equivalent to the grep command when executed with the -f command line option. the tool is also known as fixed or fast grep as it doesn't treat regular expression metacharacters as special, processing the information as simple string instead.
for example, if you want to search for dot (.) in a file, and don't want grep to interpret it as a wildcard character, use fgrep in the following way:
Example:
$ fgrep "." [file-name]
find
The find command lets you search for files or a string in a directory as well as its sub-directories.
Syntax :
find path [options]
Examples:
Find test.txt in current dir and sub dirs:
$ find . -name test.txt -print
Find all c programs in current dir and sub dirs
$ find . -name \*.c -print
To list and remove all regular files named core starting in the directory /prog that are larger than 500k, enter:
$ find /prog -type f -size +1000 -print -name core -exec rm {} \;
Modify all permissions of all files to 0700 only in ~/code directory:
$ find ~/code -exec chmod 0700 {} \;
Find a string from all java programs from ./source dir
$ find ./source -type f -name "*.java" -exec grep -il string {} \;
Find hello in all *.java file in current directory and sub directories:
$ find . -type f -name "*.java" -exec grep -il "hello" {} \;
Find all files that are created on Sep 18:
find ./ -type f -ls |grep 'Sep 18'
Find the list of files modified in the last 30 minutes
$ find . -mmin -30
Find the list of files modified in the last 20 days
$ find . -mtime -20
fmt
fmt is a simple optimal text formatter. it reformats each paragraph in the file passed to it, and writes the file contents to standard output.
$ fmt file1
fold
The fold command wraps each input line to fit in specified width.
$ fold -w 10
hi my name is userone arora
hi my name
is himans
hu arora
free
The free command displays the amount of free and used memory in the system.
$ free
total used free shared buffers cached Mem: 3924680 3654464 270216 -/+ buffers/cache: 1507216 2417464 Swap: 8388600 739904 7648696
grep
The grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern.
$ grep hello test.txt
hello...how are you?
groups
The groups command displays the name of groups a user is part of.
$ groups userone
userone : userone adm cdrom sudo dip plugdev lpadmin sambashare
gzip
The gzip command compresses the input file, replacing the file itself with one having a .gz extension.
Create a tar file and zip it: $ tar -cvf myperl.tar perl $ gzip -f myperl.tar creates zip file => myperl.tar.gz $gzip -d mytar.tar.tz The option -d decompress mytar.tar file. Decompress and untar gunzip -dc mysql-x.xx.xx.tar.gz | tar xv
$ gzip file1
gunzip
files compressed with gzip command can be restored to their original form using the gunzip command.
$ gunzip -d file1.gz
Please see gzip.
head
The head command displays the first 10 lines of the file to standard output
hostname
The hostname command not only displays the system's host name, but lets them set it as well.
$ hostname
userone-desktop
id
The id command prints user and group information for the current user or specified username.
$ id
uid=50411(userone) gid=7432(groupone) groups=7432(groupone)
join
The join command allows you to join lines of two files on a common field (default is first).
join [option]... file1 file2
kill
The kill command, as the name suggests, helps user kill a process by sending the term signal to it.
$ kill [process-id]
To kill a job or process. Find the process-id from ps -ef command
kill -9 8956
Option -9 means forced kill.
killall
The killall command lets you kill a process by name. unlike kill - which requires id of the process to be killed - killall just requires the name of the process.
$ killall nautilus
last
The last command shows listing of last logged in users.
$ last
userone pts/11 :0 thu mar 2 09:46 still logged in
userone pts/1 :0 thu mar 2 09:46 still logged in
userone :0 :0 thu mar 2 09:42 still logged in
reboot system boot 4.4.0-62-generic thu mar 2 09:41 - 10:36 (00:54)
userone pts/14 :0 wed mar 1 15:17 - 15:52 (00:35)
userone pts/13 :0 wed mar 1 14:40 - down (08:06)
ldd
The ldd command displays in output dependencies of a shared library.
$ ldd /lib/i386-linux-gnu/libcrypt-2.19.so
linux-gate.so.1 => (0xb77df000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75da000)
/lib/ld-linux.so.2 (0x80088000)
ln
The ln command is used for creating link between files. for example, the following command would create a link named 'lnk' to a file with name 'test.txt':
$ ln test.txt lnk
locate
The locate command helps user find a file by name.
$ locate [file-name]
$ locate myfile.c
/home/usr/userone/source/c/myfile.c
/home/usr/usertwo/src/c/myfile.c
logname
The logname command prints the user-name of the current user.
$ logname
userone
ls
The ls command lists contents of a directory.
$ ls
capture.png hlist.o progress progress.h sizes.c
hlist.c license progress.1 progress.o sizes.h
hlist.h makefile progress.c readme.md sizes.o
$ ls -l -rw-r--r-- 1 usr grp 58 Oct 26 14:22 a.c -rwxr-xr-x 1 usr grp 6413 Oct 26 14:22 a.out drwxr-xr-x 3 usr grp 4096 Sep 22 2016 java drwxr-xr-x 2 usr grp 4096 Sep 11 10:23 src List directories only
$ ls -l | grep ^d drwxr-xr-x 2 usr grp 4096 Oct 6 13:37 java drwxrwxr-x 2 usr grp 4096 Oct 6 13:26 src List files only no directories
$ ls -l | grep ^- -rw-r--r-- 1 usr grp 58 Oct 26 14:22 a.c -rwxr-xr-x 1 usr grp 6413 Oct 26 14:22 a.out
lshw
The lshw command extracts and displays detailed information on the hardware configuration of the machine.
$ sudo lshw
[sudo] password for userone:
userone-desktop
description: desktop computer
product: to be filled by o.e.m. (to be filled by o.e.m.)
vendor: to be filled by o.e.m.
version: to be filled by o.e.m.
serial: to be filled by o.e.m.
width: 32 bits
capabilities: smbios-2.6 dmi-2.6 smp-1.4 smp
lscpu
The lscpu command displays in output system's cpu architecture information (such as number of cpus, threads, cores, sockets, and more).
$ lscpu
architecture: i686
cpu op-mode(s): 32-bit, 64-bit
byte order: little endian
cpu(s): 1
on-line cpu(s) list: 0
thread(s) per core: 1
core(s) per socket: 1
socket(s): 1
vendor id: authenticamd
cpu family: 16
model: 6
stepping: 3
cpu mhz: 2800.234
bogomips: 5600.46
virtualization: amd-v
l1d cache: 64k
l1i cache: 64k
l2 cache: 1024k
lsof
The lsof command displays information (on stdout) related to files opened by processes. files can be of any type, including regular files, directories, block special files, character special files, executing text reference, libraries, and stream/network files.
$ lsof
COMMAND PID USER FD TYPE init 1 root cwd unknown init 1 root rtd unknown
man
man lets you access reference manual for commands, programs/utilities, as well as functions.
$ man cp
NAME cp - copy files and directories SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. etc.
md5sum
The md5sum command lets you print or check md5 (128-bit) checksums.
mkdir
The mkdir command lets you create directories.
$ mkdir [dir-name]
mkfifo
The mkfifo command is used to create named pipes.
$ mkfifo [pipe-name]
more
more is basically a filter for paging through text one screenful at a time.
$ more bigfile.log
bigfile.log will be displayed page by page.
mv
The mv command lets you either move a file from one directory to another, or rename it.
$ mv test.txt /home/userone/desktop/
nano
The nano command in linux launches the 'nano' editor. The editor is designed to emulate the features and user-friendliness of the uw pico text editor.
$ nano
or
$ nano [file-name]
nice
The nice command lets you run a program with modified scheduling priority.
$ nice -n[niceness-value] [program]
$ nice -n15 vim
nl
The nl command writes contents of a file to output, and prepends each line with line number.
$ nl file1
1 hi
2 how are you
3 bye
nm
The nm command is used to display symbols from object files.
$ nm
nm: 'a.out': No such file
$ cc a.c
$ nm 00000000006006b0 d _DYNAMIC 0000000000600848 d _GLOBAL_OFFSET_TABLE_ 00000000004005c8 R _IO_stdin_used w _Jv_RegisterClasses 0000000000600690 d __CTOR_END__ 0000000000600688 d __CTOR_LIST__ 00000000006006a0 D __DTOR_END__ 0000000000600698 d __DTOR_LIST__ 0000000000400680 r __FRAME_END__ 00000000006006a8 d __JCR_END__ 00000000006006a8 d __JCR_LIST__ etc. etc.
nproc
The nproc command displays the number of processing units available to the current process.
$ nproc
1
od
The od command lets you dump files in octal as well as some other formats.
$ od /bin/ls
0000000 042577 043114 000401 000001
000000 000000 000000 000000 0000020
...
...
...
passwd
The passwd command is used for changing passwords for user accounts.
$ passwd userone
changing password for userone.
(current) unix password:
paste
The paste command lets you merge lines of files. for example, if 'file1' contains the following lines:
$ cat file1
hi
my name is
userone
arora
i
am
a
linux researcher
and tutorial
writer
Then the following 'paste' command will join all the lines of the file:
$ paste -s file1
hi my name is userone arora i am a linux researcher and tutorial writer
pidof
The pidof command gives you the process id of a running program/process.
$ pidof nautilus
2714
ping
The ping command is used to check whether or not a system is up and responding. it sends icmp echo_request to network hosts.
Example:
$ ping google.com Pinging google.com [216.58.200.110] with 32 bytes of data: Reply from 216.58.200.110: bytes=32 time=12ms TTL=54 Reply from 216.58.200.110: bytes=32 time=14ms TTL=54 Reply from 216.58.200.110: bytes=32 time=12ms TTL=54 Reply from 216.58.200.110: bytes=32 time=13ms TTL=54 Ping statistics for 216.58.200.110: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 12ms, Maximum = 14ms, Average = 12ms
ps
The ps command displays information (in the form of a snapshot) about the currently active processes.
Examples:
$ ps
pid tty time cmd
4537 pts/1 00:00:00 bash
20592 pts/1 00:00:00 ps
$ ps -ef
Displays all processes
pstree
The pstree command produces information about running processes in the form of a tree.
$ pstree init---arptd +-arpid +-attod +-aunit---{auntd} +-crnd +-cgent.bin---27*[{cgent.bin}] +-mnbus-daemon +-ana-server---12*[{ana-server}] +-hed---hed-runner---hd-aon-api | | +-hld-aon-inpu | +-{hld} +-ieralance +-mter---pkup
pwd
The pwd command displays the name of current/working directory.
$ pwd
/home/userone
rm
The rm command lets you remove/delete files and/or directories.
$ rm [file-name]
Examples:
To delete a file called core enter:
$ rm core
To delete mydir and its sub-dirs:
$rm -R mydir
With out -R option, you get following error:
$ rm mydir rm: cannot remove `per': Is a directory Go to top
rmdir
The rmdir command allows you delete empty directories.
$ rmdir [dir-name]
scp
The scp command lets you securely copy files between systems on a network.
$ scp [name-and-path-of-file-to-transfer] [user]@[host]:[dest-path]
sdiff
The sdiff command lets you perform a side-by-side merge of differences between two files.
$ sdiff file1 file2
Content of File1 | Content of File2 :::::
sed
sed is basically a stream editor that allows users to perform basic text transformations on an input stream (a file or input from a pipeline).
seq
The seq commands prints numbers from first to last, in steps of increment. for example, if first is 1, last is 10, and increment is 2, then here's the output this command produces:
$ seq 1 2 10
1
3
5
7
9
sha1sum
The sha1sum command is used to print or check sha1 (160-bit) checksums.
$ sha1sum test.txt
955e48dfc9256866b3e5138fcea5ea0406105e68 test.txt
shutdown
The shutdown command lets user shut the system in a safe way.
$ shutdown
size
The size command lists the section sizes as well as the total size for an object or archive file.
$ size
size: 'a.out': No such file
Now create an a.out file by writing "Hello world" c program called a.c.
#include <stdio.h> main() { printf("hello\n"); } To create a.out, compile it with cc a.c
$ size a.out
text data bss dec hex filename
1204 280 4 1488 5d0 test
sleep
The sleep command lets user specify delay for a specified amount of time. you can use it to delay an operation like:
$ sleep 10; shutdown
sort
The sort command lets you sort lines of text files.
The sort command produces output in sorted order:
$ sort myfile.txt
Displays the contents in sorted order.
split
The split command, as the name suggests, splits a file into fixed-size pieces. by default, files with name like xaa, xab, and xac are produced.
$ split [file-name]
ssh
ssh is basically openssh ssh client. it provides secure encrypted communication between two untrusted hosts over an insecure network.
$ ssh [user-name]@[remote-server]
stat
The stat command displays status related to a file or a file-system.
$ stat test.txt
file: ‘test.txt’
size: 20 blocks: 8 io block: 4096 regular file
device: 801h/2049d inode: 284762 links: 2
access: (0664/-rw-rw-r--) uid: ( 0/ root) gid: ( 0/ root)
access: 2017-03-03 12:41:27.791206947 +0530
modify: 2017-02-28 16:05:15.952472926 +0530
change: 2017-03-02 11:10:00.028548636 +0530
strings
The strings command displays in output printable character sequences that are at least 4 characters long. it is used to search for printable text (strings) in binary files.
su
The su command lets you change user-identity. mostly, this command is used to become root or superuser.
$ su [user-name]
sudo
The sudo command lets a permitted user run a command as another user (usually root or superuser).
$ sudo [command]
Examples:
Login as super user
$ sudo su -
To get a file listing of an unreadable directory:
$ sudo ls /usr/local/protected
To list the home directory of user scott
$ sudo -u scott ls ~scott
sum
The sum command prints checksum and block counts for each input file.
$ sum readme.txt
45252 5
tac
The tac command prints input files in reverse. functionality-wise, it does the reverse of what the cat command does.
$ cat file2
Contents of file2
$ tac file2
Contents of file2
tail
The tail command displays in output the last 10 lines of a file.
$ tail [file-name]
Examples:
To display last 100 lines, enter:
$ tail 100 myfile.log
To displays appended data as the file grows (real time), enter:
$ tail -f system.log
talk
The talk command lets users talk with each other.
$ talk [user-name]
tar
tar is an archiving utility that lets you create as well as extract archive files. for example, to create archive.tar from files 'foo' and 'bar', use the following command:
Archive perl folder: $ tar -cvf myperl.tar perl perl/ perl/sd.pl perl/file.pl perl/blank.pl perl/seq.csv perl/seq002.csv etc... To create .gz file $ tar -czvf myperl.tar.gz perl perl/ perl/sd.pl perl/file.pl etc... Uncompress tar.gz file $ tar -xvf myperl.tar.gz or $ gzip -d myperl.tar.gz Add files or directories to tar archive file
$ tar -rvf archive.tar foo bar
tee
The tee command reads from standard input and write to standard output as well as files.
$ uname | tee file2
linux
$ cat file2
linux
test
The test command checks file types and compare values. for example, you can use it in the following way:
$ test 7 -gt 5 && echo "true"
true
time
The time command is used to summarize system resource usage of a program.
$ time ping google.com
ping google.com (216.58.220.206) 56(84) bytes of data.
64 bytes from del01s08-in-f14.1e100.net (216.58.220.206): icmp_seq=1 ttl=52 time=44.2 ms
^c
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 44.288/44.288/44.288/0.000 ms
real 0m0.676s
user 0m0.000s
sys 0m0.000s
top
The top command gives a dynamic real-time view of a running system (in terms of its processes). for example:
$ top
touch
The touch command lets you change file timestamps (the access and modification times). when name of a non-existent file is passed as an argument, that file gets created.
$ touch [file-name]
tr
The tr command can be used to translate/squeeze/delete characters. for example, here's how you can use it to convert lowercase characters to uppercase:
$ echo 'google' | tr "[:lower:]" "[:upper:]"
tty
The tty command prints the filename of the terminal connected to standard input.
$ tty
/dev/pts/10
uname
The uname command prints certain system information.
$uname
Linux
$ uname -a
linux userone-desktop 4.4.0-62-generic #83~14.04.1-ubuntu smp wed jan 18 18:10:26 utc 2017 i686 athlon i686 gnu/linux
uniq
The uniq command is used to report or remove repeated lines. for example, if 'file1' contains the following data:
$ cat file2
welcome to Linux
welcome to Linux
linux commands
Unix
The uniq command can be used to remove the repeated line.
$ uniq file1
welcome to Linux
Linux commands
Unix
unexpand
The unexpand command converts spaces present in the input file(s) into tabs, and writes the file contents to standard output.
$ unexpand file1
uptime
The uptime command tells how long the system has been running.
$ uptime
15:59:59 up 6:20, 4 users, load average: 0.81, 0.92, 0.82
users
The users command displays in output the usernames of users currently logged in to the current host.
$ users
userone userone userone userone
vdir
The vdir command lists information about contents of a directory (current directory by default).
$ vdir
total 1088
-rw-rw-r-- 1 userone userone 4850 may 20 2015 test_backup.pdf
-rw-rw-r-- 1 userone userone 2082 may 28 2015 test-filled.pdf
-rw-rw-r-- 1 userone userone 7101 may 28 2015 test.pdf
vim
vim is basically a text/programming editor. The name 'vim' stands for vi improved as the editor is upwards compatible to the vi editor.
$ vim [file-name]
w
The w command displays information about the users currently on the machine, and their processes.
$ w
16:18:07 up 6:39, 4 users, load average: 0.07, 0.32, 0.53
user tty from login@ idle jcpu pcpu what
userone :0 :0 09:39 ?xdm? 1:08m 0.25s init --user
userone pts/0 :0 09:41 6:36m 0.84s 7.84s gnome-terminal
userone pts/10 :0 14:51 0.00s 0.16s 0.00s w
userone pts/11 :0 15:41 35:19 0.05s 0.05s bash
wall
The wall command lets you write and send a message to other users that are currently logged in.
$ wall [your-message]
watch
The watch command can be used to monitor a program's output. it runs the program repeatedly, displaying its output and errors.
$ watch date
Every 2.0s: date Thu Oct 26 14:15:33 2017
Thu Oct 26 14:15:33 EST 2017
Ctrl^c
wc
The wc command prints newline, word, and byte counts for a file.
$ wc test.txt
8 18 109 test.txt
Output:
8 18 109 test.txt
8 = Lines 18 = Words 109 = Bytes
wget
The wget command line tool in linux lets you perform a non-interactive download of files from the web.
here's how you can use it:
wget [url]
whatis
The whatis command displays single-line manual page descriptions.
$ whatis mkdir
mkdir (1) - make directories
mkdir (2) - create a directory
mkdir (1posix) - make directories
which
The which command basically lets you locate a command - the file and the path of the file that gets executed.
$ which date
/bin/date
who
The who command shows who is logged on.
$ who
userone :0 2017-03-03 09:39 (:0)
userone pts/0 2017-03-03 09:41 (:0)
userone pts/10 2017-03-03 14:51 (:0)
userone pts/11 2017-03-03 15:41 (:0)
whereis
The whereis command shows in output locations of the binary, source, and manual page files for a command.
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1posix.gz /usr/share/man/man1/ls.1.gz
whoami
The whoami command prints effective userid of the current user.
$ whoami
userone
xargs
The xargs command builds and executes command lines from standard input. in layman's terms, it reads items from stdin and executes a command passed to it as an argument. for example, here's how you can use xargs to find the word "linux" in the files whose names are passed to it as input.
$ xargs grep "linux"
file1
file2
file3
file1:linux researcher
file2:a linux tutorial website
file3:linux is opensource
yes
The yes command outputs a string repeatedly until killed.
$ yes [string]
Comments
Post a Comment