If you want to
know more about your Linux system. Where can you get detailed
information?
The best way to obtain
information about your Linux system is by running the ‘uname’ command with
various options. Here are the details of the available options…
Execute ‘uname’ without
any options to display the kernel name:
# uname -s
Linux
Linux
Execute ‘uname’ with the
-r option to display the kernel release…
# uname -r
3.8.0-23-generic
3.8.0-23-generic
Execute ‘uname’ with the
-v option to display the kernel version:
# uname -v
#34-Ubuntu SMP Wed May 29 20:22:58 UTC 2013
#34-Ubuntu SMP Wed May 29 20:22:58 UTC 2013
Execute ‘uname’ with the
-m option to display the machine hardware:
# uname -m
x86_64
x86_64
Execute ‘uname’ with the
-o option to display the operating system:
# uname -o
GNU/Linux
GNU/Linux
What if you want
to read only the first or last few lines of a file?
You can use ‘head’ and
‘tail’ commands for this.
# tail -5 output
/etc/brltty/en-nabcc.ttb
/etc/brltty/brl-al-abt_small.ktb
/etc/brltty/brl-al-abt_basic.kti
/etc/acpi/mediabtn.sh
/etc/fstab.d
/etc/brltty/en-nabcc.ttb
/etc/brltty/brl-al-abt_small.ktb
/etc/brltty/brl-al-abt_basic.kti
/etc/acpi/mediabtn.sh
/etc/fstab.d
The ‘tail’ command above
displays the last five lines from the file ‘output’.
Through this command,
you can also display the last ‘n’ bytes using the -c option:
#tail -c10 output
c/fstab.d
c/fstab.d
So, you can see that
last 10 bytes were displayed in the output.
Similarly, there is a
‘head’ command to display content from the beginning of a file. Here are some
examples:
#head -10 output
/boot/abi-3.8.0-19-generic
/boot/abi-3.8.0-23-generic
/boot/grub/i386-pc/search_label.mod
/sbin/acpi_available
/sbin/ip6tables
/sbin/e2label
/sbin/ntfslabel
/sbin/swaplabel
/sbin/iptables-save
/sbin/ip6tables-restore
/boot/abi-3.8.0-19-generic
/boot/abi-3.8.0-23-generic
/boot/grub/i386-pc/search_label.mod
/sbin/acpi_available
/sbin/ip6tables
/sbin/e2label
/sbin/ntfslabel
/sbin/swaplabel
/sbin/iptables-save
/sbin/ip6tables-restore
#head -c10 output
/boot/abi-
/boot/abi-
Sometimes you know that you ran a command a while ago and you want to
run it again. You know a bit of the command, but you don’t exactly know all
options, or when you executed the command.
Of
course, you could just keep pressing the Up Arrow until you
encounter the command again, but there is a better way.
You can search the bash history in an interactive mode by pressing Ctrl + r. This will put bash in history mode,
allowing you to type a part of the command you’re looking for. In the
meanwhile, it will show the most recent occasion where the string you’re typing
was used. If it is showing you a too recent command, you can go further back in
history by pressing Ctrl + r again and again. Once you found
the command you were looking for, press enter to run it. If you can’t find what
you’re looking for and you want to try it again or if you want to get out of
history mode for an other reason, just press Ctrl + c. By the way, Ctrl
+ c can be used in many other cases to cancel the current operation
and/or start with a fresh new line.
No comments:
Post a Comment