Linux.com

Community Blogs



CLI Intro: Useful General-Purpose Commands

This tutorial is the second part of the introduction to Linux command-line. In the first chapter I tried to make a brief introduction to the shell and the basic ways of moving around. Here I will talk about several useful commands, which may be needed on a day to day basis if you're working with the shell.

 

Working with Files and Directories

Creating Directories

The command to create new directories (also called folders) is mkdir. For example, to create a directory called booksinside your home directory, you would issue the following command:

mkdir books

Renaming Files

In Linux, renaming a file is done via the mvcommand, which stands for 'move'. The general format of the command is:

mv SOURCE DESTINATION

So, if for example you would like to rename the directory created previously, books to mybooks2, you would issue the following command:

mv books mybooks2

Copying Files

The command for copying files and directories is cp. For example, to copy the file /etc/network/interfaces to you home directory you could write the following:

cp /etc/network/interfaces /home/USER

Make sure to replace USER with your username. Or, if we keep in mind that ~is automatically expanded into the home directory of the current user:

cp /etc/network/interfaces ~

And if your current working directory is already your home directory (e.g. /home/USER):

cp /etc/network/interfaces .

The character .expands into the current directory. See the first chapter to see more details on this. You could even use environment variables, which expand into a certain string. In the following example, the variable $HOME holds the path to your home directory:

cp /etc/network/interfaces $HOME
You may have noticed that if you copy a file to a path that ends in a directory (e.g. /home/USER), the file will be copied inside the respective directory, it will not delete nor replace it.

You can copy more than one file at a time, the last argument being the directory where you want the files to be copied:

cp myfile1 myfile2 myfile3 ~/books

This command will copy myfile1, myfile2 and myfile3 from the current working directory into the booksfolder, located inside your home path.

Copying Directories

Directories can be copied in the same fashion as files, only this time we will use the -r switch. This tells the cpcommand to copy directories recursively, meaning all the sub-folders and files of the specified directory.

cp -r Documents ~/books

This command will copy the Documents folder from the current directory inside the booksdirectory located in your home path.

Creating Files

To create empty files, you can use the touchcommand. In a later chapter I will discuss on how to create and edit or modify text files with various editors.

touch myfile

Removing Files

To delete a file, you would use the rmcommand:

rm myfile

To delete a directory, you will also need the -rswitch:

rm -r mybooks

Adding Users

Adding a New User

The command is adduser which is a user-friendly wrapper for the useraddcommand. More on administrating users and groups in a later chapter.

Other Commands

View the Current Date and Time

Use the datecommand for displaying the date and time:

$ date
Thu Oct  2 16:32:58 EEST 2014

In addition, you can use format specifiers to display the date and time differently. For example, you could use the %Y (year), %b (abbreviated month name), %d (number of the day, two digits), %H (hour, 24-hour format), %M (minute), %S (second):

$ date +"%Y %b %d %H:%M:%S"
2014 Oct 02 16:58:44

To change the date and time, use the --setswitch:

sudo date +"%H%M" --set="1656"

The above command will change the hour and minute to 16:56.

Calendar

The calcommand will display an ASCII calendar of the current month, and will highlight the current day:

Show Your Username

The whoami command will print the username currently logged in. Additionally, you can use the echo $USERcommand, which will use the $USER environment variable to echo (print) its value:

Print System Information

For this we will use the uname command with the -aswitch, to show all the information available:

$ uname -a
Linux mint 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux

This shows the kernel version, the date and processor architecture. Except for uname, there are two other commands which print hardware information, lspci which prints all the PCI devices, and inxi, which is a script usually available on Linux Mint systems.

$ inxi
CPU~Dual core Intel Celeron CPU G530 (-MCP-) clocked at 1600.000 Mhz Kernel~3.13.0-24-generic i686 Up~2 days Mem~824.3/3721.2MB HDD~500.1GB(68.9% used) Procs~189 Client~Shell inxi~1.8.4

inxidisplays extended information about the CPU, kernel, memory, hard-disk space and so on.

Show Uptime

The uptimecommand is used to print for how long the system has been running:

$ uptime
 17:21:25 up 2 days, 21:02,  7 users,  load average: 0.28, 0.21, 0.21

Print Text

The echocommand is used to output text:

$ echo "Hello, world!"
Hello, world!

You can use the echo -ecommand to interpret special characters (like in C):

$ echo -e "Hello,\t world\!\n\n"
Hello,   world\!

Here we used a horizontal tab (\t), and two newlines at the end (\n). Notice how the !character is escaped too.

Searching for Commands

Commands and programs usually reside inside the /bin, /sbin and /usr/bin directories. To search for a command in such standard locations, use whereis:

$ whereis cal
cal: /usr/bin/cal /usr/bin/X11/cal /usr/share/man/man1/cal.1.gz

To search for a command in all the possible locations in your $PATH, use which:

$ which cfgr.sh
/floydb/debconf/scripts/cfgr.sh
Environment variables such as $HOME, $USER or $PATH are variables which will be expanded (replaced) by the shell with the string that they hold. For example, the $PATH variable contains all the locations in which commands reside, separated by the : character. Try echo $PATH to see it.

Show File Types

Use the typecommand for this:

$ file track01.ogg 
track01.ogg: Ogg data, Vorbis audio, stereo, 44100 Hz, ~192000 bps, created by: Xiph.Org libVorbis I (1.1.0 RC1)
$ file cover.png 
cover.png: PNG image data, 320 x 317, 8-bit/color RGBA, non-interlaced

Getting Help

Usually commands have a manual page, so for any command you could use man COMMANDto read a detailed help about what it does and how to use it. The manual page lists all the parameters you can pass to the command. Once you've opened a manual page, you can navigate through it via the arrows, Ctrl+P or Ctrl+N to read the previous and respectively, next line, or Q to quit and close the manual page and return to the shell.

Commands usually have a -h or --help parameter, which will display a short description on what the command does and a compact list of parameters that it takes.

More on getting help in a following chapter.

CLI Intro: Useful General-Purpose Commands

 

SMPlayer 14.9 Review – One of the Best Movie Players for Linux

SMPlayer is a powerful video player for Linux and Windows, based on MPlayer, with countless features and options. Together with VLC, I believe there is no match for it when it comes to movie players.

smplayer00

In this article I will overview the main things that make SMPlayer stand out of the crowd, putting it on the top of the video playback applications list. SMPlayer is written in Qt 4.8 and uses MPlayer2 for video playback. Personally I have only words of praise for this player, which is why I decided to write this review. So let’s proceed and see what the most important features of SMPlayer are.

SMPlayer 14.9 Review – One of the Best Movie Players for Linux

 

Protect yourself from the big bad shellshock

It has been announced on Wednesday, that a serious vulnerability has been found in the bash program installed on Linux, Unix and MacOSX systems. Because this bug is a hidden open-door to your system, hackers can gain access to your system from the internet, a run programs completely taking over the system.

This is a serious problem, that if not handled quickly, and properly, will cause serious damage to your computer and Internet infrastructures since most of the computers servicing the Internet are running a Linux or Unix OS.

Heed these warnings. Read these links thoroughly and make sure you update your Linux, Unix and MacOS X systems with the latest patch for bash. Start patching immediately.

http://www.zdnet.com/shellshock-better-bash-patches-now-available-7000034115/

http://arstechnica.com/security/2014/09/bug-in-bash-shell-creates-big-security-hole-on-anything-with-nix-in-it/

http://www.linux.com/news/enterprise/systems-management/789720-improved-patch-tackles-new-shellshock-bash-bug-attack-vectors

 

Convergence and the Mobile Desktop

For years I have been anxiously awaiting the arrival of 'Ubuntu Edge' or some similarly convergent distribution of Linux capable of running my Android applications as well as a full Linux desktop.

 

The idea of docking my smartphone (now phablet) to get a full Linux desktop including all the applications I am accustomed to using with all the responsiveness and flexibility that we have come to expect from mature distributions such as we get currently from the open source community, is from a business perspective, the return on investment that is necessary when investing into ever more expensive technology.

Consider the cost of a laptop, tablet, and desktop in addition to the smartphone and game console we already own. Whatever your personal mix, these technologies are already blurring the lines between themselves. To bring Linux mainstream has proven a challenge in the last decades, and in my personal opinion it is because Linux has failed to differentiate itself as the innovative leader it could or should be.

Here is an opportunity to leap ahead of the competition and get to market with a fully interoperable smartphone/phablet/tablet OS that brings the flexibility of Linux/Android to the existing hardware (HD/4K anyone?) that we own.

 

Introduction of Huawei SSR1PCXLL401 board

SSR1PCXLL401 is a SDH service board which serve in Huawei OSN 1500B equipment. You could discover several names of this board, these are SSR1PCXLL4, SSR1PCXLL401, SSRD0PCXL411. In fact they describe the same item and you can use any name of it to search on the internet. Many professional HUAWEI transmission product suppliers buy this board such as thunder-link international. Reports various alarms and performance events, which facilitates the management and maintenance of the equipment. Four parts compose of SSR1PCXLL401, namely, SDH Processing Unit whose function is transmits and receives 1xSTM-1/STM-4/STM-16 optical signals; SCC Unit works on Configures and monitors services, monitors the service performance,and collects the information about the performance events and alarms; Cross-Connect Unit includes Higher order cross-connect capacity: 60(Gbit/s); Lower order cross-connect capacity: 20(Gbit/s), which matters a lot to the customers; the forth one Clock Unit provides the standard system synchronization clock. The SSR1PCXLL401 is available in one functional version, that is R1. It is used in the OSN 1500B Transmits and receives 1xSTM-1/STM-4/STM-16 optical signals. It converts the received optical signals into electrical signals and sends the electrical signals to the cross-connect side. In addition, it also converts the electrical signals sent from the cross-connect side into optical signals and transmits the optical signals. The SSR1PCXLL401 could be installed in slots 4 and 5 in the subrack. By default, slot 4 is the slot for the working board, and slot 5 is the slot for the protection board. The feature code 401 of the SSR1PCXLL401 indicates the type of optical interface is S-4.1. Some parameters that differ from the series board of SSR1PCXLL401 can be referred as follows: (S-4.1) , its transmission distance is 2 ~ 15 km; (L-4.1 ), 20~40km; (L-4.2), 50~80km and (Ve-4.2 ), 50~100km.
 

Brief Introduction of Huawei SSR2PD1A Board

The SSR2PD1A is a PDH processing board which adds tributary signals to line signals and drops tributary signals to line signals. This board has another name, SSR2PD1A01, so that you can use different names to search at Thunder-link.com which sells various transmission boards including SSR2PD1A. Thus you will enjoy your shopping tour at that site.

Huawei SSR2PD1A board

The SSR2PD1A can be used on the OptiX OSN1500B equipment to transmit/receive process 32xE1 signals. The series of PD1 is available in two functional versions, namely, R1 and R2. The difference between the two versions is with regard to their function: R2PD1supports the PRBS test in the tributary direction and in the cross-connect direction in the normal mode or MUX mode and does not support the PRBS test in the Server mode; The R1PD1 supports the PRBS test in the tributary direction and in the cross-connect direction and does not support the CRC function, but the R2PD1 supports the CRC function. The R1PD1A can be replaced with the R2PD1A when the required conditions are met. So you should pay attention to the difference.

In the case of SSR2PD1A of OptiX OSN 1500B equipment, it must be used with the D75S, D12S, or D12B. In the OptiX OSN 1500B sub-rack, the slots valid for the SSR2PD1A01 vary with the cross-connect capacity of the sub-rack. When the cross-connect capacity is 20 Gbit/s, the PD1 can be installed in divided slots 1–3, 6–8, and 11–13.The valid slots of SSR2PD1A are slot 1, 2 3, 6, 11, 12, 13, 15, 16, 17.

The feature code of the SSR2PD1A indicates the type of interface impedance. The relationship between the feature code of the PD1 and the type of interface impedance is: the feature code of SSR2PD1A and SSR1PD1 is A01; Type of Interface Impedance is 75-ohm.

Huawei transmission boards own a good word-of-mouth and a large scale market in the overseas. With the rapid development of the society and economy, the prospect of this field will be better and better. What’s more, SSR2PD1A will play a duteous board, service the people and society.

 

A Bash Script to Install/Upgrade to Linux Kernel 3.16.3 in Ubuntu/Linux Mint

The Linux Kernel 3.16.3 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.16.3 in your Linux systems.

Read more at YourOwnLinux

 

Scripting made fun

I have never been a fan of programming or scripting. Thought is was a skill I was unable to learn. When learning to administer a Linux system, scripting can not be avoided.

One of the skills every sysAdmin must learn is scripting. The benefit of scripting is to automate a task or job that is constantly run every time a system is running. A sysAdmin can make that job run on its own and concentrate on other tasks that are not so easily automated. These scripts are either written using a text editor, the shell, or, scripting language.

I was not automating anything, just getting used to writing scripts. When I was studying "Linux essentials" in preparation for the Linux certification, I was practicing passing variable values. That is, printing the value of one of my system's default variables. I had a crazy thought. What if I actually ran a script using a variable. I soon learned, Linux is what you make of it.

There are default variables already set on a Linux system. To find what these variables are, you simply type this command in a shell or terminal emulator, “printenv”

This is a screen shot of the default variables on my Linux Mint 17 system.

XDG_VTNR=7

SSH_AGENT_PID=1808

XDG_SESSION_ID=c1

TERM=xterm

SHELL=/bin/bash

XDG_SESSION_COOKIE=9f6e6efa3c8a79091dbec7c85403e053-1410643266.227255-1746036259

WINDOWID=35651588

GNOME_KEYRING_CONTROL=/run/user/1000/keyring-ccaIQh

USER=x

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:

OPENDVD=eject /dev/sr0

SSH_AUTH_SOCK=/x

PLAYMEDIA=vlc /dev/sr0

SESSION_MANAGER=x

USERNAME=x

DEFAULTS_PATH=/usr/share/gconf/default.default.path

XDG_CONFIG_DIRS=/etc/xdg/xdg-default:/etc/xdg

PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

DESKTOP_SESSION=default

GDM_XSERVER_LOCATION=local

PWD=/etc

GNOME_KEYRING_PID=1585

LANG=en_US.UTF-8

MANDATORY_PATH=/usr/share/gconf/default.mandatory.path

MDM_XSERVER_LOCATION=local

GDMSESSION=default

SHLVL=1

XDG_SEAT=seat0

HOME=/x/x

XDG_SESSION_DESKTOP=default

LOGNAME=x

XDG_DATA_DIRS=/usr/share/default:/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share/mdm/

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ONZKNCkspd,guid=10fed374626ed9dae74c359c5414b544

MDMSESSION=default

TEXTDOMAIN=im-config

WINDOWPATH=7

XDG_RUNTIME_DIR=/run/user/1000

DISPLAY=:0.0

MDM_LANG=en_US.UTF-8

TEXTDOMAINDIR=/usr/share/locale/

COLORTERM=xfce4-terminal

XAUTHORITY=/x/x/x

_=/usr/bin/printenv

Take a close look at the bold text above. These are my custom variables I set to run some custom scripts.

OPENDVD=eject /dev/sr0 is used to open my laptop's DVD disc drive.

PLAYMEDIA=vlc /dev/sr0 is used to play a DVD using VLC.

Of course I could have just written the scripts using a text editor. I wanted to make things more interesting by try something different. Also, doing this helped me learn and appreciate environmental variables much more. I find them really fun to play with.

Always remember this syntax, "command argument". The command is what you want to run, the argument is what you want it to run on. The command “VLC” opens the VLC media player program. The argument “/dev/sr0” is the DVD disc drive I want it to open. Typing this in your terminal will do just that.

If you look at the subfolder “etc”, you will notice a file named “environment”. You can actually use this filie to create and store your own custom declared variables. On some Ubuntu based systems, you might noticed the default “PATH” variable is also located there. A little F.Y.I.

Once you set your desired variable, and save the file, restart your system. Run the “printenv” command and you will see your variables listed.

To set a variable, type in all caps, the name of the variable, then after that, the “=” sign and then the value that the variable will relate to. Like this, VARIABLE=value. In my case I typed, OPENDVD=”eject /dev/sr0”. The quotes surrounding the command indicates that the command should be treated as one value.

Once this is written, I had reset my mint system. Once logged in, and the terminal was opened, I called the value of the new variable. This is when you tell your terminal to print the value of a variable. The command to do this is, prompt<$VARIABLENAME>.When I typed, “$OPENDVD”, my dvd disc drive opens. Your system will recognize a variable when it starts with a dollar sign followed by a name in all caps as in, "$OPENDVD".

I was not big on programming. Yet, scripting, using variables, not only makes Linux even more interesting but programming as well. I already have a large list of scripts I want to experiment with. When I think about it, scripting might actually be my thing. I went beyond just learning what a variable is. I begun learning how to talk to Linux using my own language.

 

Make Downloading Files Effortless

A download manager is computer software that is dedicated to the task of downloading files, optimizing bandwidth usage, and operating in a more organized way. Some web browsers, such as Firefox, include a download manager as a feature, but their implementation lacks the sophistication of a dedicated download manager (or add-ons for the web browser), without using bandwidth optimally, and without good file management features.

<A HREF="http://www.linuxlinks.com/article/20140913062041384/DownloadManagers.html">Complete article</A>

 

Install Git 2.1.0 on Ubuntu 14.04, 12.04 and LinuxMint 16/15

Git has released 2.1.0 version on Aug 15, 2014. Git is a free and open source distributed version control system . Git 2.1 comes with the number of noticeable changes than 1.9 versions. It is designed to handle a small to very large projects with speed and efficiency.


Read more at  http://tecadmin.net/install-git-on-ubuntu/

 

THE TRUTH ABOUT – HOW TO SECURELY ERASE A SOLID STATE DRIVE (SSD)

The short answer is:

Perhaps you can’t. Well, you can, but that means that you need to use a hammer.

The long answer:

You could use the build in ATA Secure Erase command (if your drive supports that), or you can overwrite the SSD multiple times, but

There are studies out there showing that the data could be recovered even after overwriting multiple times.

Read on over here...

 
Page 4 of 136

Upcoming Linux Foundation Courses

  1. LFD211 Introduction to Linux for Developers
    08 Dec » 09 Dec - Virtual
    Details
  2. LFS220 Linux System Administration
    08 Dec » 11 Dec - Virtual
    Details
  3. LFD331 Developing Linux Device Drivers
    15 Dec » 19 Dec - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board