gconf-editorHow to hidden volumes Icon on Desktop.
Posted by Dracy Labels: Linux, System Management, Ubuntu RelatedHow to use the shell command to count files in a directory (directory can have one or more subdirectories)?
And you want to output the results as follows:
(Can display the count of files in a directory)
12 ./test/dir2
16 ./test/dir3/dir4/dir5
15 ./test/dir3/dir4/dir6
23 ./test/dir3/dir4/dir7
Maybe you can use ls and wc command.But today I will introduce you a alternative way to reach this goal-Use find and uniq command.Maybe that is more easy to understand and clear to use,I think.
Let's check this command:
find . -type f -printf %h"\n" | sort | uniq -cThe first part of the command acually list the leading directories of all the files in current directory.Like the file "/usr/bin/yes" only shows its directory "/usr/bin"。That's controled by the -printf %h"\n" option of the find command.
And finally the command uniq merge the duplicate lines to the unique.And the -c option shows the repeated counts.So the count number represents the file counts in the directory at the same time.
The first image shows the output of the command:
strings /usr/bin/yes
and the second image is the output of the command:
cat /usr/bin/yes
So have you known the difference between two commands?
Yes,the strings will prints the character sequences in the binary file,but cat can't.Let's check the man's explanation.
Strings
For each file given, GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the options below) and are followed by an unprintable character.
So strings is a mainly useful command for determining the contents of non-text files.
What's the Issue?
sudo gedit /etc/apt/sources.listI will always recommend, however, that people use instead this sort of command:
gksudo gedit /etc/apt/sources.listAnd reserve sudo for command-line applications, like so:
sudo nano /etc/apt/sources.listWhy is it an issue?
1. There are other times, though, when side effects can be as mild as Firefox extensions not sticking or as extreme as as not being able to log in any more because the permissions on your .ICEauthority changed. You can read a full discussion on the issue here.
These errors occur because sometimes when sudo launches an application, it launches with root privileges but uses the user's configuration file.
For example, if you launch Firefox with the command
gksudo firefox, it uses root's Firefox configuration file.
But if you launch Firefox with the command
sudo firefox, it runs with root privileges but uses the user's configuration file (in this case, you can see the homepage and theme are different).
2. Running graphical applications with sudo also has the downside of always having to be run from the terminal. If you don't use the proper command—gksudo or kdesu, you will not be able to use the command as an icon launcher or keyboard shortcut because there will be no graphical dialogue box to enter your sudo password in.
3. There are also some graphical applications that simply will not run with the sudo command. Kate, for example, can be run asWhy not make exceptions?
kdesu kate
but cannot be run as
sudo kate
Bottom line: most of the time when you use sudo for graphical applications, it's fine. Some of the time, though, it is not fine, and is, in fact, extremely bad.But gksudo sometimes gives me an error... even though it appears to work...
If you made exceptions, you would have to give people a list of all the graphical applications that are okay to run as sudo and a list of all the graphical applications that must be run as gksudo or kdesu.
Why make a list that needs to be compiled and updated, that most people won't refer to, and that is completely unnecessary? Just be consistent in suggesting good practice: gksudo and kdesu for graphical applications. sudo for command-line applications.
You may notice that even though gksudo is the proper way to launch graphical applications, if you launch a gksudo application it will sometimes give you what appears to be an error. This, for example:
(gedit:####): GnomeUI-WARNING **: While connecting to session manager:
Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.
That is not a real error, and there's already been a bug report filed on the message appearing. The developers have seen the bug and labeled it a low priority. In the meantime, just ignore the message and keep encouraging people to not use sudo for graphical applications so they won't potentially mess up their ~/.ICEauthority and other user configuration files.
from:http://www.psychocats.net/ubuntu/graphicalsudo
Like many UNIX ® tools, ps also has a lot of options, the most commonly used are:
a: shows all tty, including other users;
x: print non-controled terminal or the tty which not controled by current terminal;
u: display user-oriented format,shows the user and the start-up time of the process.
need other relevant options, please refer to ps (1) manual page.
the ps command is commonly used as follows:
$ ps ax | less This command will print the list of all processes that is currently running , so you can find out where or what the processes that have problems, and then terminate them.
pstree
$ pstree-up | less This will allow you to overview the entire tree structure of processes .
